prettier i guess

This commit is contained in:
Dylan Pizzo
2026-01-14 12:44:20 -08:00
parent db2007e4b0
commit 07595c31ef

View File

@@ -1,13 +1,13 @@
// Import the framework and instantiate it // Import the framework and instantiate it
import Fastify from 'fastify' import Fastify from "fastify";
import fastifyStatic from '@fastify/static' import fastifyStatic from "@fastify/static";
import {fastifyWebsocket} from '@fastify/websocket'; import { fastifyWebsocket } from "@fastify/websocket";
import { routeList } from "./routelist.ts"; import { routeList } from "./routelist.ts";
import { attachRoute } from "./util/routewrap.ts"; import { attachRoute } from "./util/routewrap.ts";
import { git } from './util/git.ts'; import { git } from "./util/git.ts";
import path from "path"; import path from "path";
import {fileURLToPath} from 'url'; import { fileURLToPath } from "url";
const __dirname = fileURLToPath(new URL('.', import.meta.url)); const __dirname = fileURLToPath(new URL(".", import.meta.url));
await git.clone({ await git.clone({
from: "https://github.com/thisismypassport/shrinko8", from: "https://github.com/thisismypassport/shrinko8",
@@ -15,23 +15,23 @@ await git.clone({
}); });
const server = Fastify({ const server = Fastify({
logger: true logger: true,
}); });
server.register(fastifyWebsocket); server.register(fastifyWebsocket);
server.register(fastifyStatic, { server.register(fastifyStatic, {
root: new URL('public', import.meta.url).toString().slice("file://".length), root: new URL("public", import.meta.url).toString().slice("file://".length),
prefix: '/', prefix: "/",
}); });
routeList.forEach(firRoute => { routeList.forEach((firRoute) => {
attachRoute(server, firRoute); attachRoute(server, firRoute);
}); });
server.setNotFoundHandler((req, res) => { server.setNotFoundHandler((req, res) => {
if (!req.url.startsWith("/api")) { if (!req.url.startsWith("/api")) {
res.sendFile('index.html'); res.sendFile("index.html");
} }
}); });
@@ -40,8 +40,11 @@ try {
// Note: host needs to be 0.0.0.0 rather than omitted or localhost, otherwise // Note: host needs to be 0.0.0.0 rather than omitted or localhost, otherwise
// it always returns an empty reply when used inside docker... // it always returns an empty reply when used inside docker...
// See: https://github.com/fastify/fastify/issues/935 // See: https://github.com/fastify/fastify/issues/935
await server.listen({ port: parseInt(process.env["PORT"] ?? "3000"), host: "0.0.0.0" }) await server.listen({
port: parseInt(process.env["PORT"] ?? "3000"),
host: "0.0.0.0",
});
} catch (err) { } catch (err) {
server.log.error(err) server.log.error(err);
process.exit(1) process.exit(1);
} }