mirror of
https://github.com/detleph/server.git
synced 2026-09-04 08:36:06 +02:00
Add debugging code
+ Small fix in the event controller + Add development flag to the dev container
This commit is contained in:
@@ -52,6 +52,7 @@ if [ "$RECREATE" = true ]; then
|
||||
-p $D_PORT:$D_PORT -e PORT=$D_PORT \
|
||||
-e DATABASE_PASSWORD=server \
|
||||
-e DATABASE_URL="postgresql://server:server@postgres:5432/management?schema=public" \
|
||||
-e NODE_ENV="development" \
|
||||
--entrypoint "/app/scripts/docker-entrypoint.dev.sh" \
|
||||
node
|
||||
fi
|
||||
|
||||
@@ -14,13 +14,13 @@ export const getAllEvents = async (req: Request, res: Response) => {
|
||||
id: false,
|
||||
},
|
||||
});
|
||||
if (events.length > 0)
|
||||
res.status(200).json({
|
||||
type: "success",
|
||||
payload: {
|
||||
events,
|
||||
},
|
||||
});
|
||||
|
||||
res.status(200).json({
|
||||
type: "success",
|
||||
payload: {
|
||||
events,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export const getEvent = async (req: Request, res: Response) => {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { NextFunction, Request, Response } from "express";
|
||||
import logger from "../error/logger";
|
||||
|
||||
export default function debugLogger(req: Request, res: Response, next: NextFunction) {
|
||||
// Only log when in development mode
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
logger.debug(`Request to: ${req.url}`);
|
||||
next();
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import organisationRouter from "./Routes/organisation.routes";
|
||||
import groupRouter from "./Routes/group.routes";
|
||||
import defaultErrorHandler from "./Middleware/error/handler";
|
||||
import logger from "./Middleware/error/logger";
|
||||
import debugLogger from "./Middleware/debug/logger";
|
||||
|
||||
// Set up async error handling
|
||||
require("express-async-errors");
|
||||
@@ -16,6 +17,10 @@ require("dotenv").config(); // Load dotenv config
|
||||
|
||||
const app = express();
|
||||
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
logger.info("Using development mode");
|
||||
}
|
||||
|
||||
async function main() {
|
||||
// Dev
|
||||
await prisma.admin.upsert({
|
||||
@@ -34,6 +39,8 @@ async function main() {
|
||||
app.use(express.urlencoded({ extended: true }));
|
||||
app.use(express.json());
|
||||
|
||||
app.use(debugLogger);
|
||||
|
||||
// Admin authentication endpoints
|
||||
app.use("/api/authentication", adminAuthRouter);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user