Skip to content

NeaByteLab/Deserve

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deserve

Build HTTP server effortlessly with zero configuration for productivity.

Deno JSR CI License

Features

  • Zero Config — No build step. Point to routes and serve.
  • File-Based Routing — Put route files in a folder, URL follows that structure.
  • Context — Body, query, params, cookies, headers, plus helpers to respond.
  • Middleware — Global or per path. CORS, auth, session, WebSocket.
  • Static Files — Serve directories with optional cache and etag.
  • Error Handling — Custom or default HTML/JSON error responses.
  • Worker Pool — Offload heavy work to a pool so the server stays responsive.
  • Frontend Optional — Use any frontend. Deserve stays the server.

Installation

Note

Prerequisites: Deno 2.5.4 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 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 routeroutes/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' })
}

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

  • Bugs & ideasGitHub Issues
  • Code & docsPull Requests welcome.
  • Use it — Try Deserve in your projects and share feedback.

License

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