started integrating auth with lucia

This commit is contained in:
Milo Schwartz 2024-10-01 20:48:03 -04:00
parent a33a8d7367
commit fc5dca136f
No known key found for this signature in database
20 changed files with 1341 additions and 61 deletions

View file

@ -0,0 +1,23 @@
import { ErrorRequestHandler, NextFunction, Response } from "express";
import ErrorResponse from "@server/types/ErrorResponse";
import HttpCode from "@server/types/HttpCode";
import logger from "@server/logger";
import environment from "@server/environment";
export const errorHandlerMiddleware: ErrorRequestHandler = (
error,
req,
res: Response<ErrorResponse>,
next: NextFunction,
) => {
logger.error(error);
const statusCode = error.statusCode || HttpCode.INTERNAL_SERVER_ERROR;
res?.status(statusCode).send({
data: null,
success: false,
error: true,
message: error.message || "Internal Server Error",
status: statusCode,
stack: environment.ENVIRONMENT === "prod" ? null : error.stack,
});
};