Skip to content

Instantly share code, notes, and snippets.

@magurotuna
Created August 6, 2021 12:29
Show Gist options
  • Save magurotuna/22b79d5506a8c7a4834646691c534825 to your computer and use it in GitHub Desktop.
Save magurotuna/22b79d5506a8c7a4834646691c534825 to your computer and use it in GitHub Desktop.
import {
Application,
Router,
Status,
} from "https://deno.land/x/oak@v7.5.0/mod.ts";
function createApp(): Application {
const app = new Application();
const router = new Router();
router.all("/success", (ctx) => {
ctx.response.body = "success!";
ctx.response.status = Status.OK;
})
router.all("/fail", (ctx) => {
ctx.response.status = Status.InternalServerError;
})
app.use(router.routes());
return app;
}
const app = createApp();
addEventListener("fetch", app.fetchEventHandler());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment