Get up and running with Deserve in under 5 minutes!
By the end of this guide, you'll have this project structure:
.
├── main.ts
└── routes/
└── index.ts
Create main.ts:
// 1. Import Router
import { Router } from '@neabyte/deserve'
// 2. Create router instance (default routesDir: ./routes)
const router = new Router()
// 3. Start server on port 8000
await router.serve(8000)Create a routes folder and add index.ts:
// 1. Import Context type
import type { Context } from '@neabyte/deserve'
// 2. Export handler named after HTTP method (GET) — file-based routing
export function GET(ctx: Context): Response {
// 3. Send JSON response
return ctx.send.json({
message: 'Hello from Deserve!',
timestamp: new Date().toISOString()
})
}deno run --allow-net --allow-read main.tscurl http://localhost:8000You should see:
{
"message": "Hello from Deserve!",
"timestamp": "2077-01-01T00:00:00.000Z"
}