mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-05 18:27:18 +00:00
32 lines
802 B
JavaScript
32 lines
802 B
JavaScript
import Fastify from "fastify";
|
|
import fastifyStatic from "@fastify/static";
|
|
import path from "node:path";
|
|
|
|
const fastify = Fastify({ logger: true });
|
|
|
|
fastify.get("/env.js", (req, reply) => {
|
|
reply.header("Content-Type", "application/javascript; charset=utf8");
|
|
reply.send(`window.API_URL = ${JSON.stringify(process.env.API_URL)}`);
|
|
});
|
|
|
|
fastify.register(fastifyStatic, {
|
|
root: path.join(__dirname, "dist"),
|
|
wildcard: false,
|
|
});
|
|
|
|
fastify.get("*", (req, reply) => {
|
|
reply.header("Content-Type", "text/html; charset=utf8").send(indexContent);
|
|
});
|
|
|
|
fastify.listen({ port: 3002, host: '0.0.0.0' }, (err, address) => {
|
|
if (err) {
|
|
throw err;
|
|
}
|
|
console.log(`Server listening on ${address}`);
|
|
});
|
|
|
|
process.on("SIGTERM", () => {
|
|
fastify.close().then(() => {
|
|
process.exit(0);
|
|
});
|
|
});
|