Bun adapter for Tupik: serves an app with Bun.serve.
bun add @tupik/bun @tupik/coreRun with bun run server.ts:
import { createApp, createModule } from '@tupik/core';
import { serveBun } from '@tupik/bun';
const app = createApp().register(
createModule().get('/', { access: 'public', handler: () => ({ runtime: 'bun' }) }),
);
const server = serveBun(app, { port: 3000 });
const response = await fetch('http://localhost:3000/');
console.log(await response.json()); // { runtime: 'bun' }
server.stop();| Export | Purpose |
|---|---|
serveBun(app, { port?, hostname? }) |
Starts Bun.serve with the app's paths as native routes and fetch as fallback; returns the server (stop()) |
createBunRoutes(app, handler) / toBunPath(path) |
The routes object serveBun builds |
createBunHandler(app) |
Bare fetch handler for Bun.serve({ fetch }) |
MIT