Skip to content

NeaByteLab/Deserve

Deserve

Build HTTP server effortlessly with zero configuration for productivity.

Deno JSR CI License

Features

  • Zero Config - No build step, point at routes and serve.
  • File-Based Routing - Route files in a folder mirror the URL.
  • Context - Read request data and respond through one object.
  • Middleware - Run global or per-path logic before handlers.
  • Validation - Check body, query, and params before handlers.
  • Static Files - Serve directories with optional cache and etag.
  • Rendering - Build dynamic HTML from templates with streaming.
  • Error Handling - Catch every error with custom or default responses.
  • Observability - Subscribe to lifecycle, request, and error events.
  • Hot Reload - Routes and templates reload without a restart.
  • Worker Pool - Offload CPU-bound work to keep server responsive.

Installation

Note

Prerequisites: Deno 2.7.0 or later.

# Add Deserve from JSR
deno add jsr:@neabyte/deserve

See the installation guide for details.

Quick Start

Create a routes directory and export HTTP method handlers. Start the server.

import { Router } from 'jsr:@neabyte/deserve'

// Create router pointing at routes directory
const router = new Router({ routesDir: './routes' })

// Optional worker pool for CPU-bound work
// const router = new Router({
//   routesDir: './routes',
//   worker: { scriptURL: import.meta.resolve('./worker.ts'), poolSize: 4 }
// })
// Read handle: ctx.getState('worker' as never)

// Start server on port 8000
await router.serve(8000)

Example route in routes/hello.ts:

import type { Context } from 'jsr:@neabyte/deserve'

// Export GET, POST, PUT, path from file location
export function GET(ctx: Context): Response {
  return ctx.send.json({ message: 'Hello from Deserve' })
}

Build & Test

From the repo root (requires Deno).

Check - format, lint, and typecheck:

# Format, lint, and typecheck source
deno task check

Test - run tests (under tests/, uses --allow-read for fixtures):

# Run tests in tests/ (uses --allow-read for fixtures)
deno task test

Benchmark - autocannon runs. benchmark/README.md for details.

Documentation

Full documentation (EN / ID): docs-deserve.neabyte.com

DVE Editor (Syntax Highlighting)

Contributing

License

This project is licensed under the MIT license. See LICENSE for details.