@bullet-js/http
v1.0.0
Published
The HTTP foundation for BulletJS. Handles routing, middleware, and request/response pipelines.
Readme
@bullet-js/http
The HTTP foundation for BulletJS. Handles routing, middleware, and request/response pipelines.
Features
- 🗺️ Expressive Routing: Define routes with a familiar fluent API.
- 🛡️ Middleware Pipelines: Robust middleware system using the onion pattern.
- 🚦 Throttling: Built-in IP-based rate limiting.
- 📥 Simplified Request: Easy access to inputs, headers, and IP identification.
Installation
bun add @bullet-js/httpUsage
Simple Routing
import { Route } from '@bullet-js/http';
Route.get('/', async (req) => {
return { message: 'Hello World' };
});Middleware & Throttling
import { Route, throttle } from '@bullet-js/http';
Route.get('/heavy-process', async () => 'Processing...')
.middleware(throttle(10, 1)); // 10 requests per minuteRoute Parameters
Route.get('/users/:id', async (req) => {
const id = req.param('id');
return `User: ${id}`;
});