Created
November 27, 2022 11:56
-
-
Save YuzuRyo61/42ebe7023d3eb07a99b6c5a6e955e394 to your computer and use it in GitHub Desktop.
DenoとHonoでWebアプリ、ユニットテストも軽く書いたやつ
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 { assertEquals } from 'std/testing/asserts.ts'; | |
import { app } from './app.ts'; | |
Deno.test('Should be HTTP status is 200', async () => { | |
// Request URL must be an absolute path | |
const res = await app.request('http://localhost:8000/'); | |
// assert | |
assertEquals(res.status, 200); | |
}); |
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 { Hono } from "hono/mod.ts"; | |
export const app = new Hono(); | |
app.get('/', (c) => c.text('Hello! Hono!')); |
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
Show hidden characters
{ | |
// import map | |
"importMap": "import_map.json", | |
// tasks | |
"tasks": { | |
"start": "deno run --allow-net ./main.ts" | |
} | |
} |
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
{ | |
"imports": { | |
"std/": "https://deno.land/[email protected]/", | |
"hono/": "https://deno.land/x/[email protected]/" | |
} | |
} |
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 { serve } from "std/http/server.ts"; | |
import { app } from "./app.ts"; | |
await serve(app.fetch); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment