dev (#160)
Some checks failed
continuous-integration/drone/push Build is failing

Co-authored-by: sora-ext
Co-authored-by: soraefir
Reviewed-on: #160
This commit is contained in:
2025-03-02 01:09:29 +01:00
parent 977751d517
commit aee79aac75
67 changed files with 6060 additions and 5661 deletions

36
src/server/main.ts Normal file
View File

@ -0,0 +1,36 @@
import fastify from 'fastify'
import fastify_static from '@fastify/static'
import fastify_db from '@fastify/leveldb'
import fastify_view from '@fastify/view';
import pug from 'pug'
import { join as pathJoin } from "path";
import api from "./api"
const server = fastify(); //{ logger: true });
server.register(fastify_static, {
root: pathJoin(__dirname, "../public"),
prefix: "/public/",
});
server.register(
fastify_db as any,
{ name: "db" }
);
server.register(fastify_view, {
engine: { pug: pug },
});
server.register(api, { prefix: "/api" });
server.get("/", (req, reply) => reply.view("/src/template/home.pug"));
server.get("/:id", (req, reply) => reply.view("/src/template/journey.pug"));
server.get("/view/:id", (req, reply) => reply.view("/src/template/view.pug"));
server.get("/short/:id", (req, reply) => reply.view("/src/template/short.pug"));
server.listen({ port: 8080, host: "0.0.0.0" }, (err, address) => {
if (err) throw err;
console.log("Listening on", address);
});