fix: add the redis extension conditionally (#5524)

* fix: add the redis extension conditionally

* chore: import order and stuff

* fix: added logger, error handling and routing

* feat: configured sentry with source maps

* fix: sentry config and returning json

* fix: remove on change logs

* fix: add pretty print
This commit is contained in:
M. Palanikannan 2024-09-05 18:15:46 +05:30 committed by GitHub
parent 406ffcd7de
commit e1380f52ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 644 additions and 212 deletions

View file

@ -0,0 +1,21 @@
import { ErrorRequestHandler } from "express";
import { manualLogger } from "@/core/helpers/logger.js";
export const errorHandler: ErrorRequestHandler = (err, _req, res, _next) => {
// Log the error
manualLogger.error(err);
// Set the response status
res.status(err.status || 500);
// Send the response
res.json({
error: {
message:
process.env.NODE_ENV === "production"
? "An unexpected error occurred"
: err.message,
...(process.env.NODE_ENV !== "production" && { stack: err.stack }),
},
});
};

View file

@ -0,0 +1,15 @@
import { pinoHttp } from "pino-http";
const transport = {
target: "pino-pretty",
options: {
colorize: true,
},
};
export const logger = pinoHttp({
level: "info",
transport: transport,
});
export const manualLogger = logger.logger;