A middleware framework for handling HTTP with Deno CLI, Deno Deploy, Cloudflare Workers, Node.js, and Bun.
oak is inspired by koa.
A minimal router server which responds with content on /
.
import { Application } from "jsr:@oak/oak/application"; import { Router } from "jsr:@oak/oak/router"; const router = new Router(); router.get("/", (ctx) => { ctx.response.body = `<!DOCTYPE html> <html> <head><title>Hello oak!</title><head> <body> <h1>Hello oak!</h1> </body> </html> `; }); const app = new Application(); app.use(router.routes()); app.use(router.allowedMethods()); app.listen({ port: 8080 });
You will have to install the package and then:
import { Application } from "@oak/oak/application"; import { Router } from "@oak/oak/router"; const router = new Router(); router.get("/", (ctx) => { ctx.response.body = `<!DOCTYPE html> <html> <head><title>Hello oak!</title><head> <body> <h1>Hello oak!</h1> </body> </html> `; }); const app = new Application(); app.use(router.routes()); app.use(router.allowedMethods()); app.listen({ port: 8080 });
You will have to install the package and then:
import { Application } from "@oak/oak/application"; import { Router } from "@oak/oak/router"; const router = new Router(); router.get("/", (ctx) => { ctx.response.body = `<!DOCTYPE html> <html> <head><title>Hello oak!</title><head> <body> <h1>Hello oak!</h1> </body> </html> `; }); const app = new Application(); app.use(router.routes()); app.use(router.allowedMethods()); export default { fetch: app.fetch };
Add Package
deno add jsr:@oak/oak
Import symbol
import * as oak from "@oak/oak";
---- OR ----
Import directly with a jsr specifier
import * as oak from "jsr:@oak/oak";
Add Package
npx jsr add @oak/oak
Import symbol
import * as oak from "@oak/oak";
Add Package
yarn dlx jsr add @oak/oak
Import symbol
import * as oak from "@oak/oak";
Add Package
pnpm dlx jsr add @oak/oak
Import symbol
import * as oak from "@oak/oak";
Add Package
bunx jsr add @oak/oak
Import symbol
import * as oak from "@oak/oak";