Routing
Query & body
Path parameters, query strings and request bodies all arrive as one thing: values on the event. A single accessor reads them, so your handler never branches on where a value came from, only on what it means.
#One accessor for everything
event.get(key, default?) reads a value whatever its source. The typed overload event.get<T>(key, default) documents the shape you expect. Precedence and the raw containers are available when you need to be explicit.
@Get('/')
list (event: IncomingHttpEvent) {
const status = event.get<string>('status', 'all') // ?status=done
const limit = Number(event.get<string>('limit', '20'))
return this.tasks.list({ status, limit })
}
@Post('/')
create (event: IncomingHttpEvent) {
const title = event.get<string>('title') // from the body
return this.tasks.add(title)
}#Reading specific sources
| Accessor | Type | Description |
|---|---|---|
| event.get(k, d?) | (key, default?) | Read a value from any source (params, query, body), with an optional default. |
| event.has(k) | (key) | Whether a key is present. |
| event.query | URLSearchParams-like | The parsed query string. |
| event.body | unknown | The parsed request body (JSON, form, ...). |
| event.params | Record<string, string> | The captured path parameters. |