- Zero Config — No build step for the server. Point to a routes directory and serve.
- File-Based Routing — Drop files in
routes/; exportGET,POST, etc. File structure is your API. - Context — Request wrapper: body (JSON/form/text), query, params, cookies, headers,
ctx.send. - Middleware — Global, path-specific. CORS, SecHeaders, Body Limit, Basic Auth, Session, WebSocket.
- Static Files —
router.static(urlPath, options)with optional etag and cache-control. - Error Handling — Pluggable error response builder and error middleware; default HTML/JSON by
Accept. - Worker Pool — Optional worker pool for CPU-bound work; enable via
worker: { scriptURL, poolSize }. - Frontend Optional — Use any stack (Vite, React, etc.); Deserve stays the server.
Note
Prerequisites: Deno 2.5.4 or later.
# Add Deserve from JSR
deno add jsr:@neabyte/deserveSee the installation guide for details.
Create a routes directory and export HTTP method handlers. Start the server.
import { Router } from 'jsr:@neabyte/deserve'
// Create router and point to your routes directory
const router = new Router({ routesDir: './routes' })
// Optional: enable worker pool for CPU-bound work (ctx.state.worker.run(payload) in routes)
// const router = new Router({
// routesDir: './routes',
// worker: { scriptURL: import.meta.resolve('./worker.ts'), poolSize: 4 }
// })
// Start server on port 8000
await router.serve(8000)Example route — routes/hello.ts:
import type { Context } from 'jsr:@neabyte/deserve'
// Export GET (or POST, PUT, etc.) — path comes from file location
export function GET(ctx: Context) {
return ctx.send.json({ message: 'Hello from Deserve' })
}From the repo root (requires Deno).
Check — format, lint, and typecheck:
# Format, lint, and typecheck source
deno task checkTest — run tests (under tests/, uses --allow-read for fixtures):
# Run tests in tests/ (uses --allow-read for fixtures)
deno task testBenchmark — performance runs with autocannon; see benchmark/README.md for how to run and interpret results.
Full docs (EN / ID): docs-deserve.neabyte.com
- Getting Started — Installation, Quick Start, Server & Routes configuration
- Core Concepts — Philosophy, file-based routing, route patterns, Context, request handling
- Middleware — Global, route-specific, Basic Auth, Body Limit, CORS, Security Headers, WebSocket
- Response — JSON, text, HTML, file/data download, redirect, custom
- Static Files — Basic and multiple directories
- Error Handling — Default behavior, error object details
- Bugs & ideas — GitHub Issues
- Code & docs — Pull Requests welcome; docs support English and Indonesian.
- Use it — Try Deserve in your projects and share feedback.
This project is licensed under the MIT license. See LICENSE for details.