mirror of
https://github.com/detleph/server.git
synced 2026-09-08 16:06:19 +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 \
|
-p $D_PORT:$D_PORT -e PORT=$D_PORT \
|
||||||
-e DATABASE_PASSWORD=server \
|
-e DATABASE_PASSWORD=server \
|
||||||
-e DATABASE_URL="postgresql://server:server@postgres:5432/management?schema=public" \
|
-e DATABASE_URL="postgresql://server:server@postgres:5432/management?schema=public" \
|
||||||
|
-e NODE_ENV="development" \
|
||||||
--entrypoint "/app/scripts/docker-entrypoint.dev.sh" \
|
--entrypoint "/app/scripts/docker-entrypoint.dev.sh" \
|
||||||
node
|
node
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -14,13 +14,13 @@ export const getAllEvents = async (req: Request, res: Response) => {
|
|||||||
id: false,
|
id: false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (events.length > 0)
|
|
||||||
res.status(200).json({
|
res.status(200).json({
|
||||||
type: "success",
|
type: "success",
|
||||||
payload: {
|
payload: {
|
||||||
events,
|
events,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getEvent = async (req: Request, res: Response) => {
|
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 groupRouter from "./Routes/group.routes";
|
||||||
import defaultErrorHandler from "./Middleware/error/handler";
|
import defaultErrorHandler from "./Middleware/error/handler";
|
||||||
import logger from "./Middleware/error/logger";
|
import logger from "./Middleware/error/logger";
|
||||||
|
import debugLogger from "./Middleware/debug/logger";
|
||||||
|
|
||||||
// Set up async error handling
|
// Set up async error handling
|
||||||
require("express-async-errors");
|
require("express-async-errors");
|
||||||
@@ -16,6 +17,10 @@ require("dotenv").config(); // Load dotenv config
|
|||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV === "development") {
|
||||||
|
logger.info("Using development mode");
|
||||||
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
// Dev
|
// Dev
|
||||||
await prisma.admin.upsert({
|
await prisma.admin.upsert({
|
||||||
@@ -34,6 +39,8 @@ async function main() {
|
|||||||
app.use(express.urlencoded({ extended: true }));
|
app.use(express.urlencoded({ extended: true }));
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
|
||||||
|
app.use(debugLogger);
|
||||||
|
|
||||||
// Admin authentication endpoints
|
// Admin authentication endpoints
|
||||||
app.use("/api/authentication", adminAuthRouter);
|
app.use("/api/authentication", adminAuthRouter);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user