Skip to content

Latest commit

 

History

History

bun

Folders and files

README.md

@tupik/bun

Bun adapter for Tupik: serves an app with Bun.serve.

Install

bun add @tupik/bun @tupik/core

Usage

Run 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();

Key API

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 })

License

MIT