@ripple-ts/adapter-bun
v0.2.216
Published
Bun adapter for Ripple metaframework (Web Request/Response bridge)
Readme
@ripple-ts/adapter-bun
Bun adapter for Ripple metaframework apps.
It exposes the same serve(fetch_handler, options?) contract as
@ripple-ts/adapter-node, backed by Bun.serve.
Installation
pnpm add @ripple-ts/adapter-bun
# or
npm install @ripple-ts/adapter-bun
# or
yarn add @ripple-ts/adapter-bunUsage
import { serve } from '@ripple-ts/adapter-bun';
const app = serve(async (request) => {
const url = new URL(request.url);
if (url.pathname === '/health') {
return new Response('ok');
}
return new Response('Hello from Ripple adapter-bun!', {
headers: { 'content-type': 'text/plain; charset=utf-8' },
});
});
app.listen(3000);API
serve(fetch_handler, options?)
fetch_handler:(request: Request, platform?: any) => Response | Promise<Response>options.port(default:3000)options.hostname(default:localhost)options.static(default:{ dir: 'public' }): serves static files before middleware/handleroptions.static.dir(default:public, resolved fromprocess.cwd())options.static.prefix(default:/)options.static.maxAge(default:86400)options.static.immutable(default:false)- set
options.static = falseto disable automatic static serving
options.middleware(optional):(request, server, next) => Response | Promise<Response> | void
Returns:
listen(port?): starts Bun server and returns the Bun server instanceclose(): stops the current Bun server instance
serveStatic(dir, options?)
Creates a Bun middleware that serves static assets from dir.
options.prefix(default:/)options.maxAge(default:86400)options.immutable(default:false)
Notes
- Requires Bun runtime (
Bun.serve). - Static file logic and MIME type mappings are shared from
@ripple-ts/adapter. platformpassed tofetch_handlercontains{ bun_server }.- Unhandled errors return
500 Internal Server Error.
License
MIT
