Composables for Node.js
Type-safe event context. Lazy by design.
Composables for Node.js
Type-safe event context. Lazy by design.
Every event gets a typed, extensible state — not ad-hoc properties on req. Declare slots, compute lazily, cache automatically.
HTTP, WebSocket, CLI, Workflows — the same composable pattern works everywhere. Learn once, use anywhere.
Body parsing, cookie reading, auth extraction — nothing runs until you call it. Auth fails with a 100KB body? Wooks rejects 3.5× faster.
Fully typed context slots, route params, and composable return values. Type safety through compile-time branding.
Regex constraints, multi-wildcards, optional params. Fastest on enterprise-grade route patterns — ahead of Hono, Fastify, and h3.
defineWook() lets you create reusable, cached, typed composables — like building your own useAuth().
// Middleware chain + req/res threading
app.post('/users',
bodyParser.json(),
authenticate,
async (req, res) => {
res.status(201).json({ name: req.body.name })
}
)// Just call what you need
app.post('/users', async () => {
await useAuthorization()
const user = await useBody().parseBody<User>()
return { name: user.name } // status 201 is default for POST
})HTTP, WebSocket, CLI, Workflows — the same composable API everywhere. Learn once, use anywhere.
import { createHttpApp, useRouteParams } from '@wooksjs/event-http'
import { useBody } from '@wooksjs/http-body'
const app = createHttpApp()
app.post('/users/:org', async () => {
const { parseBody } = useBody()
const { get } = useRouteParams<{ org: string }>()
const user = await parseBody<{ name: string }>()
return { org: get('org'), created: user.name }
})
app.listen(3000)