Platforms

Bun

Running mion APIs on Bun runtime for maximum performance.
Bun support is experimental. While it works well for most use cases, some edge cases may not be fully tested.

Installation

bun add @mionkit/bun @mionkit/router

Quick Start

import {initMionBun} from '@mionkit/bun';
import {routes} from './bun-routes.ts';

const server = Bun.serve({
    port: 3000,
    fetch: initMionBun(routes),
});

console.log(`Server running at http://localhost:${server.port}`);

Configuration

You can pass configuration options to initMionBun:

import {initMionBun} from '@mionkit/bun';
import {routes} from './bun-routes.ts';

const handler = initMionBun(routes, {
    prefix: '/api', // API prefix
    // ... other router options
});
Bun's native HTTP server is extremely fast and can handle high throughput workloads efficiently.

Type Reference

BunHttpOptions

export interface BunHttpOptions {
    port: number;
    /** Bun's native Server Options */
    options: BunServeOptions;
    /** Set of default response header to add to every response*/
    defaultResponseHeaders: Record<string, string>;
    /**
     * 256KB by default, same as lambda payload
     * @link https://docs.aws.amazon.com/lambda/latest/operatorguide/payload.html
     * */
    maxBodySize: number; // default 256KB
}