Skip to content

Instantly share code, notes, and snippets.

@YuzuRyo61
Created November 27, 2022 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YuzuRyo61/42ebe7023d3eb07a99b6c5a6e955e394 to your computer and use it in GitHub Desktop.
Save YuzuRyo61/42ebe7023d3eb07a99b6c5a6e955e394 to your computer and use it in GitHub Desktop.
DenoとHonoでWebアプリ、ユニットテストも軽く書いたやつ
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);
});
import { Hono } from "hono/mod.ts";
export const app = new Hono();
app.get('/', (c) => c.text('Hello! Hono!'));
{
// import map
"importMap": "import_map.json",
// tasks
"tasks": {
"start": "deno run --allow-net ./main.ts"
}
}
{
"imports": {
"std/": "https://deno.land/std@0.166.0/",
"hono/": "https://deno.land/x/hono@v2.5.2/"
}
}
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