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:
parent
406ffcd7de
commit
e1380f52ec
12 changed files with 644 additions and 212 deletions
21
live/src/core/helpers/error-handler.ts
Normal file
21
live/src/core/helpers/error-handler.ts
Normal 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 }),
|
||||
},
|
||||
});
|
||||
};
|
||||
15
live/src/core/helpers/logger.ts
Normal file
15
live/src/core/helpers/logger.ts
Normal 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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue