Skip to main content
Module

x/doa/example.ts

A middleware framework for Deno's http serve🦕. Transplanted from Koa with ❤️
Latest
File
import { App } from "./app.ts";
const app = new App();
// loggerapp.use(async (ctx, next) => { await next(); const rt = ctx.response.get("X-Response-Time"); console.log(`${ctx.method} ${ctx.url} - ${rt}`);});
// x-response-timeapp.use(async (ctx, next) => { const start = Date.now(); await next(); const ms = Date.now() - start; ctx.set("X-Response-Time", `${ms}ms`);});
// responseapp.use(async (ctx) => { ctx.status = 200; ctx.cookies.set("name", "johannlai"); ctx.set("x-user-name", "johann"); ctx.body = "Hello World";});
app.on("error", (err: any) => { console.error("server error", err);});
await app.listen({ port: 8000 });