Function bunway

  • Factory function users import.

    Example usage:

    import { bunway } from "bunway";
    const app = bunway();
    app.get("/", (ctx) => ctx.res.text("OK"));
    app.listen();

    Middleware helpers (json, urlencoded, text, bodyParser) are available as static properties mirroring Express' API.

    Parameters

    Returns BunWayApp

Properties

bodyParser: ((options?) => Handler)

Type declaration

json: ((options?) => Handler)

Type declaration

    • (options?): Handler
    • Parse application/json requests.

      app.use(json());
      app.use(json({ limit: 2 * 1024 * 1024, type: [/json$/, "application/vnd.api+json"] }));

      Parameters

      • options: JsonParserOptions = {}

      Returns Handler

text: ((options?) => Handler)

Type declaration

    • (options?): Handler
    • Parse plain text (text/plain) payloads.

      app.use(text());
      app.use(text({ type: /text/(plain|csv)/ }));

      Parameters

      • options: TextParserOptions = {}

      Returns Handler

urlencoded: ((options?) => Handler)

Type declaration

    • (options?): Handler
    • Parse application/x-www-form-urlencoded bodies (HTML form submissions).

      app.use(urlencoded());
      app.use(urlencoded({ limit: 64 * 1024 }));

      Parameters

      • options: UrlencodedParserOptions = {}

      Returns Handler