refactor(routes): routes to modules + feat(auth): auth middleware basic structure done
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import express from "express";
|
||||
import config from "./config";
|
||||
import cors from "cors";
|
||||
import { routes } from "./routes";
|
||||
import { routes } from "./modules";
|
||||
import { authorizationMiddleware } from "./modules/auth/auth.middleware";
|
||||
|
||||
const app = express();
|
||||
const port = config.port;
|
||||
@@ -12,6 +13,7 @@ if (config.enableCors) {
|
||||
|
||||
app.use(express.json());
|
||||
// Global middleware
|
||||
app.use(authorizationMiddleware as any);
|
||||
app.use((req, _res, next) => {
|
||||
console.log(`LOG: new ${req.method} request for ${req.url}`);
|
||||
next();
|
||||
@@ -23,7 +25,7 @@ app.use("/example", (req, _res, next) => {
|
||||
next();
|
||||
});
|
||||
|
||||
app.use("/api/v1", routes); // / serves as the base for the imported routes
|
||||
app.use(config.baseRoute, routes); // / serves as the base for the imported routes
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Server running at http://localhost:${port}`);
|
||||
|
||||
Reference in New Issue
Block a user