-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
57 lines (47 loc) · 1.64 KB
/
index.ts
File metadata and controls
57 lines (47 loc) · 1.64 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { BaseSeedSource as SSBUCharacterSeedSource } from "@db/BaseSeedSource";
import { init_tables, init_views, seed_db } from "@db/init_tables";
import { serve } from "@hono/node-server";
import { honoLogger } from "@logtape/hono";
import { configure, getConsoleSink } from "@logtape/logtape";
import guild_router from "@v1/guild/router";
import match_router from "@v1/match/router";
import season_router from "@v1/season/router";
import { Hono } from "hono";
import { requestId } from "hono/request-id";
import { openAPIRouteHandler } from "hono-openapi";
await configure({
sinks: { console: getConsoleSink() },
loggers: [
{ category: ["grindcord"], sinks: ["console"], lowestLevel: "trace" },
{ category: ["hono"], sinks: ["console"], lowestLevel: "info" },
],
});
const app = new Hono({ strict: false });
await init_tables();
await seed_db(new SSBUCharacterSeedSource());
await init_views();
app.use(requestId());
app.use(honoLogger());
app.get("/", (c) => {
return c.text("Hello Hono!");
});
app.route("/match", match_router);
app.route("/season", season_router);
app.route("/guild", guild_router);
// app.route("/user", _router);
app.get(
"/openapi.json",
openAPIRouteHandler(app, {
documentation: {
info: {
title: "Grindcord REST API",
version: "0.0.1",
description: "Grindcord OpenAPI Reference",
},
servers: [{ url: "http://localhost:3000", description: "Local Server" }],
},
}),
);
serve({ fetch: app.fetch, port: 3000 }, (info) => {
console.log(`Server is running on http://localhost:${info.port}`);
});