OTM/server.js
soraefir 0e27042c8c
Some checks failed
continuous-integration/drone/push Build is failing
Prettier
2023-07-19 12:29:44 +02:00

36 lines
911 B
JavaScript

const fastify = require("fastify")(); //{ logger: true });
const path = require("path");
fastify.register(require("@fastify/static"), {
root: path.join(__dirname, "public"),
prefix: "/public/",
});
fastify.register(
require("@fastify/leveldb"),
{
name: "db",
},
(err) => {
if (err) throw err;
},
);
fastify.register(require("@fastify/view"), {
engine: {
pug: require("pug"),
},
});
fastify.register(require("./router/api"), { prefix: "/api" });
fastify.get("/", (req, reply) => reply.view("/template/home.pug"));
fastify.get("/:id", (req, reply) => reply.view("/template/journey.pug"));
fastify.get("/view/:id", (req, reply) => reply.view("/template/view.pug"));
fastify.get("/short/:id", (req, reply) => reply.view("/template/short.pug"));
fastify.listen({ port: 8080, host: "0.0.0.0" }, (err, address) => {
if (err) throw err;
console.log("Listening on", address);
});