initial release

This commit is contained in:
Dennis Gunia
2026-01-08 19:10:51 +01:00
commit 3f1a218ea2
16 changed files with 1009 additions and 0 deletions

61
api-gateway/src/index.ts Normal file
View File

@@ -0,0 +1,61 @@
import { BibleProvider } from "./providers/bible.provider.js";
import express from 'express';
import defaultRouter from "./routes/default.routes.js";
import config from "./config/config.js";
import helmet from "helmet";
import { exit } from "process";
import { DownloaderProvider } from "./providers/downloader.provider.js";
//BibleProvider.load_biliothek();
//console.log(`Loaded ${BibleProvider.biliothek.length} translations in biliothek`);
//const downloader = new DownloaderProvider.Downloader('SLT');
//downloader.start();
const app = express();
app.use(express.json());
app.use(helmet())
app.disable('x-powered-by')
app.use((req: express.Request, res: express.Response, next: express.NextFunction) => {
// log accessed url
// calculate processing time
const start = Date.now();
next();
const duration = Date.now() - start;
const access_log = {
date: new Date().toISOString(),
method: req.method,
url: req.url,
ip: req.ip,
agent: req.headers['user-agent'] || '',
status: res.statusCode,
duration: duration
}
console.log(access_log);
});
app.use('/', defaultRouter);
app.use((err: any, req: express.Request, res: express.Response, next: express.NextFunction) => {
console.error(err.stack);
res.status(500).json({
requested_at: new Date().toISOString(),
rescource: "error",
data: {
message: 'Internal Server Error'
},
success: false
});
});
app.listen(config.port, () => {
console.log(`Server running on port ${config.port}`);
});