-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
45 lines (41 loc) · 1.32 KB
/
main.ts
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
import { Hono } from "hono";
import { cors } from "hono/cors";
import { fromHono } from "chanfana";
import { makeBadge, ValidationError } from "badge-maker";
import { config } from "./lib/config.ts";
import { servers, tags, description, contact } from "./lib/metadata.ts";
import { generateSvg, hcbBalanceOps, hcbDonateButton } from "./api/badges.ts";
import { ping } from "./api/meta.ts";
const app = new Hono();
app.use(cors());
const openapi = fromHono(app, {
schema: {
info: {
version: "0.1.0",
title: "Badges API for lorebooks.wiki",
description,
termsOfService:
"https://github.com/lorebooks-wiki/badges-api/blob/main/docs/api-terms.md",
license: {
name: "AGPL-3.0",
url: "https://github.com/lorebooks-wiki/badges-api/blob/main/LICENSE",
},
contact,
},
servers,
tags,
externalDocs: {
url: "https://github.com/lorebooks-wiki/badges-api/tree/main/docs",
description: "More docuemntation available in GitHub repository",
},
},
docs_url: "/docs",
});
openapi.get("/hcb/balance", hcbBalanceOps);
openapi.get("/hcb/donate", hcbDonateButton);
openapi.get("/badges/:project/:badgeName", generateSvg);
openapi.get("/ping", ping);
app.get("/", (c) => {
return c.redirect(config.homepage);
});
Deno.serve({ port: config.port }, app.fetch);