ff-admin-server/src/routes/index.ts

30 lines
810 B
TypeScript
Raw Normal View History

import express from "express";
2024-08-25 13:36:19 +02:00
import type { Express } from "express";
import cors from "cors";
2024-08-25 13:36:19 +02:00
import allowSetup from "../middleware/allowSetup";
import authenticate from "../middleware/authenticate";
2024-08-25 13:36:19 +02:00
import errorHandler from "../middleware/errorHandler";
2024-08-25 13:36:19 +02:00
import setup from "./setup";
import auth from "./auth";
2024-08-27 11:47:27 +02:00
import PermissionHelper from "../helpers/permissionHelper";
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);
app.use("/auth", auth);
app.use(authenticate);
2024-08-27 17:54:59 +02:00
app.use("/secured", PermissionHelper.passCheckMiddleware("admin", "user"), (req, res) => {});
app.use(errorHandler);
};