-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tsx
33 lines (27 loc) · 1.1 KB
/
main.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/** @jsx jsx */
/** @jsxFrag Fragment */
import * as routes from "./routes/mod.ts";
import { bundle } from "https://deno.land/x/emit@0.38.2/mod.ts";
import { Hono } from "hono/mod.ts";
import { jsx, serveStatic } from "hono/middleware.ts";
const bundledJsResponse = (entryPoint: string) => () =>
bundle(import.meta.resolve(entryPoint)).then(({ code }) => {
const headers = { "Content-Type": "application/javascript" };
return new Response(code, { headers });
});
const app = new Hono();
app.get("/", (c) => c.html(<routes.Index />));
app.get("/style.css", routes.styleCss);
app.get(
"/BIZUDPGothic-Regular.ttf",
serveStatic({ path: "static/BIZUDPGothic-Regular.ttf" }),
);
app.get("/list.mjs", bundledJsResponse("./lib/client/list.ts"));
app.get("/favicon.:ext", serveStatic({ path: "static/favicon.svg" }));
app.get("/sitemap.txt", routes.sitemap);
app.get("/page.js", bundledJsResponse("./lib/client/page.ts"));
app.get("/:lawId{[0-9]{3}[0-9A-Z]{12}}/:path?", routes.lawDetail);
app.get("/:lawNo/:path?", routes.redirect)
Deno.serve(app.fetch).finished.then(() => {
console.log("Server stopped.");
});