mirror of
https://github.com/andwati/order-service.git
synced 2026-10-28 23:02:16 +00:00
to the moon
This commit is contained in:
+1
-2
@@ -6,8 +6,7 @@
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"start": "node dist/server.js",
|
||||
"dev": "nodemon src/server.ts",
|
||||
"dev": "node dist/server.js",
|
||||
"lint": "eslint . --ext .ts",
|
||||
"lint:fix": "eslint . --ext .ts --fix",
|
||||
"prettier": "prettier --check .",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ZodError } from "zod";
|
||||
import type { Request, Response, NextFunction } from "express";
|
||||
|
||||
export function errorHandler(
|
||||
@@ -6,6 +7,16 @@ export function errorHandler(
|
||||
res: Response,
|
||||
_next: NextFunction,
|
||||
) {
|
||||
if (err instanceof ZodError) {
|
||||
res.status(400).json({
|
||||
error: {
|
||||
message: "Validation Error",
|
||||
details: err.issues,
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
console.error(err);
|
||||
const statusCode = err.statusCode ?? 500;
|
||||
const message = err.message ?? "Internal Server Error";
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import * as jwt from "jsonwebtoken";
|
||||
import jwt from "jsonwebtoken";
|
||||
import { env } from "../config/env.js";
|
||||
|
||||
export interface JwtPayload {
|
||||
|
||||
Reference in New Issue
Block a user