mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-19 04:09:26 +00:00
enabled sentry
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
|
"watch": "tsc -w",
|
||||||
"start": "nodemon dist/server.js",
|
"start": "nodemon dist/server.js",
|
||||||
"dev:server": "ts-node-dev --respawn --transpile-only --ignore node_modules src/server.ts"
|
"dev:server": "ts-node-dev --respawn --transpile-only --ignore node_modules src/server.ts"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,15 +29,6 @@ app.use(upload.single("media"));
|
|||||||
app.use("/public", express.static(uploadConfig.directory));
|
app.use("/public", express.static(uploadConfig.directory));
|
||||||
app.use(routes);
|
app.use(routes);
|
||||||
|
|
||||||
app.use(async (err: Error, req: Request, res: Response, _: NextFunction) => {
|
|
||||||
if (err instanceof AppError) {
|
|
||||||
return res.status(err.statusCode).json({ error: err.message });
|
|
||||||
}
|
|
||||||
|
|
||||||
console.error(err);
|
|
||||||
return res.status(500).json({ error: "Internal server error" });
|
|
||||||
});
|
|
||||||
|
|
||||||
const server = app.listen(process.env.PORT, () => {
|
const server = app.listen(process.env.PORT, () => {
|
||||||
console.log(`Server started on port: ${process.env.PORT}`);
|
console.log(`Server started on port: ${process.env.PORT}`);
|
||||||
});
|
});
|
||||||
@@ -75,14 +66,13 @@ const startWhatsAppSessions = async () => {
|
|||||||
};
|
};
|
||||||
startWhatsAppSessions();
|
startWhatsAppSessions();
|
||||||
|
|
||||||
// app.use(Sentry.Handlers.errorHandler());
|
app.use(Sentry.Handlers.errorHandler());
|
||||||
|
|
||||||
// app.use(async (err, req, res, next) => {
|
app.use(async (err: Error, req: Request, res: Response, _: NextFunction) => {
|
||||||
// if (process.env.NODE_ENV === "DEVELOPMENT") {
|
if (err instanceof AppError) {
|
||||||
// const errors = await new Youch(err, req).toJSON();
|
return res.status(err.statusCode).json({ error: err.message });
|
||||||
// console.log(err);
|
}
|
||||||
// return res.status(500).json(errors);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return res.status(500).json({ error: "Internal server error" });
|
console.error(err);
|
||||||
// });
|
return res.status(500).json({ error: "Internal server error" });
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user