UNPKG

bunway

Version:

Express-style routing toolkit built natively for Bun.

37 lines 1.27 kB
import { BunWayApp, bunway as createBunwayApp, } from "./server"; import { json, text, urlencoded } from "./middlewares/bodyParser"; const bunwayFactory = ((options) => createBunwayApp(options)); bunwayFactory.json = json; bunwayFactory.urlencoded = urlencoded; bunwayFactory.text = text; bunwayFactory.bodyParser = (options) => { return async (ctx, next) => { if (options) ctx.req.applyBodyParserOverrides(options); await next(); }; }; /** * Factory function users import. * * Example usage: * ```ts * 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. */ export const bunway = bunwayFactory; // Core exports export { BunWayApp, BUNWAY_DEFAULT_PORT } from "./server"; export { Router } from "./core/router"; export { WayContext, WayRequest, WayResponse } from "./core/context"; export { json, urlencoded, text } from "./middlewares/bodyParser"; export { cors } from "./middlewares/cors"; export { HttpError } from "./core/errors"; export { errorHandler } from "./middlewares/errorHandler"; //# sourceMappingURL=index.js.map