2024-08-22 11:40:31 +02:00
|
|
|
import express from "express";
|
2024-08-25 13:36:19 +02:00
|
|
|
import type { Express } from "express";
|
2024-08-22 11:40:31 +02:00
|
|
|
import cors from "cors";
|
|
|
|
|
2024-08-25 13:36:19 +02:00
|
|
|
import allowSetup from "../middleware/allowSetup";
|
2024-08-22 11:40:31 +02:00
|
|
|
import authenticate from "../middleware/authenticate";
|
2024-08-25 13:36:19 +02:00
|
|
|
import errorHandler from "../middleware/errorHandler";
|
2024-08-22 11:40:31 +02:00
|
|
|
|
2024-08-25 13:36:19 +02:00
|
|
|
import setup from "./setup";
|
2024-08-22 11:40:31 +02:00
|
|
|
import auth from "./auth";
|
2024-08-27 11:47:27 +02:00
|
|
|
import PermissionHelper from "../helpers/permissionHelper";
|
2024-08-22 11:40:31 +02:00
|
|
|
|
|
|
|
export default (app: Express) => {
|
|
|
|
app.set("query parser", "extended");
|
|
|
|
app.use(express.json());
|
|
|
|
app.use(
|
|
|
|
express.urlencoded({
|
|
|
|
extended: true,
|
|
|
|
})
|
|
|
|
);
|
|
|
|
app.use(cors());
|
|
|
|
app.options("*", cors());
|
|
|
|
|
2024-08-25 13:36:19 +02:00
|
|
|
app.use("/setup", allowSetup, setup);
|
2024-08-22 11:40:31 +02:00
|
|
|
app.use("/auth", auth);
|
|
|
|
app.use(authenticate);
|
2024-08-27 17:54:59 +02:00
|
|
|
app.use("/secured", PermissionHelper.passCheckMiddleware("admin", "user"), (req, res) => {});
|
2024-08-22 11:40:31 +02:00
|
|
|
app.use(errorHandler);
|
|
|
|
};
|