-
Notifications
You must be signed in to change notification settings - Fork 0
/
duofiction.main.ts
84 lines (70 loc) · 1.98 KB
/
duofiction.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import "$std/dotenv/load.ts";
import * as serverModule from "@modules/server/mod.ts";
import { Logger } from "@modules/logger/mod.ts";
import config from "@modules/config/mod.ts";
import manifest from "./duofiction.manifest.ts";
const NAVBAR_LINKS = [
{ text: "🏠 Home", href: "/" },
{ text: "📚 Catalog", href: "/catalog/pages/1" },
{ text: "🏷️ Tags", href: "/tags" },
{ text: "🌐 Languages", href: "/languages" },
];
const STYLESHEETS = [
"https://cdn.jsdelivr.net/npm/halfmoon@2.0.1/css/halfmoon.min.css",
"https://cdn.jsdelivr.net/npm/victormono@latest/dist/index.min.css",
"/styles/main.css",
];
const logger = Logger.create({
severity: config.ENVIRONMENT === "DEVELOPMENT"
? Logger.SeverityName.Debug
: Logger.SeverityName.Informational,
application: config.NAME,
environment: config.ENVIRONMENT,
mode: config.ENVIRONMENT === "DEVELOPMENT"
? Logger.Mode.Pretty
: Logger.Mode.Json,
});
const application = serverModule.createApplication({
routes: { dir: "./routes", mergeParams: true, caseSensitive: false },
logger,
views: {
dir: "./views",
},
locals: {
title: config.TITLE,
isProduction: config.ENVIRONMENT === "PRODUCTION",
stylesheets: STYLESHEETS,
navLinks: NAVBAR_LINKS,
},
statics: {
dir: "./static",
maxAge: 3_600_00,
immutable: true,
},
manifest,
});
const server = application.listen(config.PORT, handleListening);
// server.on("")
function handleListening() {
logger.info("listening");
}
server.on("close", handleClose);
Deno.addSignalListener("SIGTERM", handleKillSignal);
Deno.addSignalListener("SIGINT", handleKillSignal);
function handleClose() {
application.logger.info("Shutting down application.");
}
async function handleKillSignal() {
console.log();
await server.close();
}
declare global {
namespace Express {
interface Locals {
title: string;
isProduction: boolean;
stylesheets: string[];
navLinks: { text: string; href: string }[];
}
}
}