Skip to content

adrianoBP/bun-conductor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bun-conductor

Extremely basic and simple router module for Bun.

Usage

import Router from 'bun-conductor'
const router = new Router();

router.serveAPI();
router.post('path', handler);

Bun.serve({
  fetch(req) { return router.handle(req); },
});

The handler must return a Response object.

Static Files

Allows a folder to be served as static files.

import Router from 'bun-conductor'
const router = new Router();

router.serveClient('client');

Bun.serve({
  fetch(req) { return router.handle(req); },
});

Sub Paths

import Router from 'bun-conductor'
const router = new Router();

// Define the new router
const testRouter = new Router();
testRouter.get('hello-world', () => {
  return new Response('Hello World from /api/test/hello-world');
})

// Define the new segment and its router
router.use('test', testRouter)

// Serve the API
router.serveAPI();

// Run the server
Bun.serve({
  fetch(req) { return router.handle(req); },
});

About

Router module for Bun

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors