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