Deno router fast, lightweight, close to runtime best practices. The easiest way to enjoy Deno.
import { App } from 'https://deno.land/x/toruk/mod.ts'
new App()
.get('/', () => new Response('Hello World'))
.get('/users/:id', ({ params }) => new Response(`User ${params.id}`))
.serve()
Path uses URLPattern matching.
Handler functions follow the same signature as Deno's serve handler.
import { App } from 'https://deno.land/x/toruk/mod.ts'
new App()
.post('/users/:id/posts', async ({ request, info, params }) => {
const body = await request.json()
return new Response(`Post ${body.id} created for user ${params.id}`)
})
.serve()
import { App } from 'https://deno.land/x/toruk/mod.ts'
new App({
router: {
routes: [
{
path: '/',
handler: () => new Response('Hello World'),
children: [
{
path: 'users/:id',
handler: ({ params }) => new Response(`User ${params.id}`),
},
],
},
],
},
})
.serve()
import { App } from 'https://deno.land/x/toruk/mod.ts'
import { cors } from 'https://deno.land/x/toruk/middlewares/mod.ts'
new App()
.use(cors())
.get('/', () => new Response('Hello World'))
.serve()