-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.ts
40 lines (34 loc) · 1.12 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
import { PupTelemetry } from "@pup/telemetry";
import languagePlugin from "localekit_fresh";
import languageConfig from "config/translate.config.ts";
import { start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts";
import { langFromUrl } from "utils/common.ts";
import { log, setLevel } from "./utils/log.ts";
import { InvalidateCache } from "./utils/datacache.ts";
const tm = new PupTelemetry();
// Clear cache on telemetry request
tm.on("clear_cache", (data) => {
// deno-lint-ignore no-explicit-any
const cacheName = (data as any).cache;
log("info", `Received request to clear cache '${cacheName}' fron IPC`);
InvalidateCache(cacheName);
});
// Enable debugging
if (Deno.args.includes("--debug")) {
log("info", "Enabling debug logging");
setLevel("debug");
}
// Start front end
start(
manifest,
{
plugins: [languagePlugin({ ...languageConfig })],
render: (ctx, render) => {
// Set <html lang=...> to a best guess from url
ctx.lang = langFromUrl(ctx.url);
render();
},
port: parseInt(Deno.env.get("PUP_CLUSTER_PORT") ?? (Deno.env.get("SPOTWEB_PORT") ?? "6000"), 10),
},
);