oak

Oak

Specific best practices and architectural patterns when working with Oak.

Details

Language / Topic
typescriptTypeScript
Category
framework

Rules

balanced

Oak (Deno)

- Use `Router` for route definitions and `Application` for middleware composition — middleware executes in order via `app.use()`. Access request body with `ctx.request.body()` and set response with `ctx.response.body`.

Oak (Deno)

- Use `Router` for route definitions and `Application` for middleware composition — middleware executes in order via `app.use()`. Access request body with `ctx.request.body()` and set response with `ctx.response.body`.
- Use middleware for cross-cutting concerns: logging, error handling, CORS, auth. Return proper status codes with `ctx.response.status`. Use `ctx.state` for passing data between middleware. Serve static files with `send()` from `oak/send`. Handle errors with `app.addEventListener("error", handler)`.