Refactor loan and user management components and backend routes
- Updated LoanTable component to fetch loan data from new API endpoint and display notes. - Enhanced UserTable component to include additional user fields (first name, last name, email, admin status) and updated input handling. - Modified fetcher utility to use new user data API endpoint. - Adjusted login functionality to point to the new admin login endpoint and handle unauthorized access. - Refactored user actions utility to align with updated API endpoints for user management. - Updated backend routes for user and loan data management to reflect new structure and naming conventions. - Revised SQL schema and mock data to accommodate new fields and constraints. - Changed Docker configuration to use the new database name.
This commit is contained in:
@@ -1,43 +1,51 @@
|
||||
import express from "express";
|
||||
import cors from "cors";
|
||||
import env from "dotenv";
|
||||
import info from "./info.json" assert { type: "json" };
|
||||
|
||||
// frontend routes
|
||||
import loansMgmtRouter from "./routes/app/loanMgmt.route.js";
|
||||
import userMgmtRouter from "./routes/app/userMgmt.route.js";
|
||||
import userMgmtRouterAPP from "./routes/app/userMgmt.route.js";
|
||||
|
||||
// admin routes
|
||||
import userDataMgmtRouter from "./routes/admin/userDataMgmt.route.js";
|
||||
import loanDataMgmtRouter from "./routes/admin/loanDataMgmt.route.js";
|
||||
import itemDataMgmtRouter from "./routes/admin/itemDataMgmt.route.js";
|
||||
import apiDataMgmtRouter from "./routes/admin/apiDataMgmt.route.js";
|
||||
import userMgmtRouterADMIN from "./routes/admin/userMgmt.route.js";
|
||||
|
||||
env.config();
|
||||
const app = express();
|
||||
const port = 8002;
|
||||
const port = 8004;
|
||||
|
||||
app.use(cors());
|
||||
// Body-Parser VOR den Routen registrieren
|
||||
app.use(express.json({ limit: "10mb" }));
|
||||
app.use(express.urlencoded({ extended: true, limit: "10mb" }));
|
||||
|
||||
// frontend routes
|
||||
app.use("/api/loans", loansMgmtRouter);
|
||||
app.use("/api/users", userMgmtRouter);
|
||||
app.use("/api/users", userMgmtRouterAPP);
|
||||
|
||||
// admin routes
|
||||
app.use("/api/admin/loan-data", loanDataMgmtRouter);
|
||||
app.use("/api/admin/user-data", userDataMgmtRouter);
|
||||
app.use("/api/admin/item-data", itemDataMgmtRouter);
|
||||
app.use("/api/admin/api-data", apiDataMgmtRouter);
|
||||
app.use("/api/admin/user-mgmt", userMgmtRouterADMIN);
|
||||
|
||||
// Increase body size limits to support large CSV JSON payloads
|
||||
app.use(express.urlencoded({ extended: true, limit: "10mb" }));
|
||||
app.set("view engine", "ejs");
|
||||
app.use(express.json({ limit: "10mb" }));
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Server is running on port: ${port}`);
|
||||
});
|
||||
|
||||
app.get("/", (req, res) => {
|
||||
res.send(info);
|
||||
});
|
||||
|
||||
// error handling code
|
||||
app.use((err, req, res, next) => {
|
||||
// Log the error stack and send a generic error response
|
||||
console.error(err.stack);
|
||||
res.status(500).send("Something broke!");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user