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 @mionjs/platform-bun @mionjs/router

Quick Start

import {startBunServer} from '@mionjs/platform-bun';
import {initMionRouter} from '@mionjs/router';
import {routes} from './bun-routes.ts';

await initMionRouter(routes);

const server = await startBunServer({port: 3000});

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

Configuration

You can pass configuration options to initMionBun:

import {startBunServer} from '@mionjs/platform-bun';
import {initMionRouter} from '@mionjs/router';
import {routes} from './bun-routes.ts';

await initMionRouter(routes, {
    basePath: 'api', // API prefix
});

await startBunServer({port: 3000});
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
}