Created
August 6, 2021 12:29
-
-
Save magurotuna/22b79d5506a8c7a4834646691c534825 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
Application, | |
Router, | |
Status, | |
} from "https://deno.land/x/[email protected]/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