refactor(express): express set as default backend

This commit is contained in:
2024-10-29 23:57:47 +01:00
parent dcd1debc73
commit 15fb5a3163
66 changed files with 861 additions and 11559 deletions

View File

@@ -1,33 +0,0 @@
import express from "express";
import config from "./config";
import cors from "cors";
import { routes } from "./modules";
import { authorizationMiddleware } from "./modules/auth/auth.middleware";
const app = express();
const port = config.port;
if (config.enableCors) {
app.use(cors());
}
app.use(express.json());
// Global middleware
app.use(authorizationMiddleware as any); // TODO: move out of here
app.use((req, _res, next) => {
console.log(`LOG: new ${req.method} request for ${req.url}`);
next();
});
// Route specific middleware
app.use("/example", (req, _res, next) => {
console.log(`LOG: new ${req.method} example request for ${req.url}`);
next();
});
app.use(config.baseRoute, routes); // / serves as the base for the imported routes
app.listen(port, () => {
console.log(`Server running at http://localhost:${port}`);
});