Files
LupiNex-Connect/servers/gateway/server.js
T
2026-06-29 20:14:06 +02:00

32 lines
971 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
! /servers/gateway/server.js Central Gateway Server Manager
? This module orchestrates the express lifecycle, handles initialization, middleware configs and router integrations
*/
// % import nodejs packages
const express = require('express');
const http = require('http');
const path = require('path');
// % import external dependencies
const rootDir = path.resolve(__dirname, '..', '..');
const { dirs } = require(path.resolve(rootDir, 'configuration', 'mapping.js'));
// % set up express server
const app = express();
const server = http.createServer(app);
// $ server setup
app.use(express.json()); // add json support for express
// $ router setup
const router = require(path.resolve(dirs.gatewayDir, 'routers'));
app.use(router);
// $ server functions
const {
boot, shutdown, restart, status
} = require(path.resolve(dirs.gatewayDir, 'functions.js'));
// $ export server module
module.exports = { boot, shutdown, restart, status, server };