Quick Start
Get up and running with Deserve in under 5 minutes!
Project Structure
By the end of this guide, you'll have this project structure:
.
├── main.ts
└── routes/
└── index.ts1. Create Your Server
Create main.ts:
typescript
// 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)2. Create Your First Route
Create a routes folder and add index.ts:
typescript
// 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()
})
}3. Run Your Server
bash
deno run --allow-net --allow-read main.ts4. Test Your API
bash
curl http://localhost:8000You should see:
json
{
"message": "Hello from Deserve!",
"timestamp": "2077-01-01T00:00:00.000Z"
}