generated at
oak
概要
DenoのWebフレームワーク
Node.jsKoaに影響を受けているようです
Node.js/Bun/Cloudflare Workersもサポートされています

Router
typescript
export { Application, Router, } from "https://deno.land/x/oak@v6.3.1/mod.ts"; const app = new Application(); const router = new Router({ prefix: "/api" }); router.get("/feeds", (ctx) => getFeeds(ctx)); router.post("/feeds", (ctx) => addFeed(ctx)); app.use(router.routes()); app.use(router.allowedMethods()); const port = 3000; await app.listen({ port });

HTTPエラーの取扱について
Context#throw
Context#assert
typescript
const body = await ctx.request.body(); ctx.assert(body.type === "json", 400); // 一つ目の引数が`false`なら400エラーを返却します