0.2.1 • Published 1 month ago

elysia-msgpack v0.2.1

Weekly downloads
-
License
-
Repository
-
Last release
1 month ago

elysia-msgpack

The library for elysia which allows you to work with MessagePack. To pack/unpack it, we use really fast msgpackr

Installation

bun install elysia-msgpack

Usage

import Elysia from "elysia"
import { msgpack } from "elysia-msgpack"

new Elysia()
    .use(msgpack())
    .post("/", ({ body }) => {
        // body is unpacked MessagePack if content-type header contains application/x-msgpack


        // if accept header contains application/x-msgpack
        // this response will become a MessagePack,
        // and if not, it will remain JSON
        return {
            some: "values",
            and: true,
            keys: 228,
        }
    })
    .listen(3000)

Options

All options of msgpackr constructor

and mimeType - it's value to detect msgpack content-type and responding with it if accept contains this mimeType. Default is application/x-msgpack.

new Elysia()
    .use(msgpack({
        mimeType: "application/some-another-msgpack-type",
        int64AsType: "string",
        // and other msgpackr constructor options
    }))

You can use Apidog to test the API with msgpack.

0.2.1

1 month ago

0.1.0

3 months ago

0.0.5

4 months ago

0.0.4

4 months ago

0.0.3

4 months ago

0.0.2

5 months ago

0.0.1

5 months ago