Initial commit

This commit is contained in:
2026-08-30 15:23:57 +02:00
commit dab5679098
1293 changed files with 240952 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
/*
! /servers/gateway/routers/index.js Central Gateway Routing Aggregator
? This module dynamically collects and registeres all modular ".router.js" files within the "routers" directory
*/
// % import nodejs packages
const router = require('express').Router();
const path = require('path');
const fs = require('fs');
// % import external dependencies
const rootDir = path.resolve(__dirname, '..', '..', '..');
const { dirs } = require(path.resolve(rootDir, 'configuration', 'mapping.js'));
// % read router files recursively
const routerRoot = path.resolve(dirs.gatewayDir, 'routers');
const routerFiles = fs.readdirSync(routerRoot)
.filter(file => /\.router\.js$/.test(file))
.sort((a, b) => {
if (a === 'root.router.js') return 1;
if (b === 'root.router.js') return -1;
return a.localeCompare(b);
});
// $ configure used routers
routerFiles.forEach(file => {
const routerPath = path.resolve(routerRoot, file);
router.use(require(routerPath));
});
// § export router module
module.exports = router;
@@ -0,0 +1,30 @@
/*
! /servers/gateway/routers/template.router.js
*/
// % import nodejs dependencies
const router = require('express').Router();
// % import external dependencies
const rootDir = path.resolve(__dirname, '..', '..', '..');
const { dirs } = require(path.resolve(rootDir, 'configuration', 'mapping.js'));
const { gatewayEvents, sendToWs } = path.resolve(dirs.gateway, 'functions.js');
// $ template router with websocket integration
router.post('/test', (req, res) => {
const correlationId = '';
sendToWs({
type: 'actionName',
correlationId,
data: req.body
});
// ~ wait for callback through central event bus
gatewayEvents.once('ws_message', (msg) => {
if (msg.correlationId === correlationId) res.json(msg.data);
});
});
// § export routers
module.exports = router;