chore(nginx): The routes /, /robots.txt, /favicon.ico were moved to nginx for the web microservice. Added html page to the home route

This commit is contained in:
Данил 2025-02-13 12:43:09 +03:00
parent 907b614f25
commit 6bae4dabfc
14 changed files with 1480 additions and 28 deletions

38
web/main.js Normal file
View file

@ -0,0 +1,38 @@
const logger = require("../shared/logger");
const config = require("../shared/config/src/main.js")();
const fs = require("fs");
const path = require("node:path");
const fastify = require("fastify")({
logger: config["server"]["log"]["print"] ? logger : false,
...(config["server"]["ssl"]["work"]
? {
https: {
key: fs.readFileSync(config["server"]["ssl"]["private_key"], "utf8"),
cert: fs.readFileSync(config["server"]["ssl"]["cert"], "utf8"),
},
}
: false),
});
fastify.register(require('@fastify/static'), {
root: path.join(__dirname, 'src/static'),
prefix: '/static/',
});
fastify.register(require('./routes/home.js'));
fastify.listen(
{
port: 3050,
host: config["server"]["host"] ? config["server"]["host"] : "localhost",
},
(err) => {
if (err) {
fastify.log.error(err);
process.exit(1);
}
},
);