to the moon

This commit is contained in:
2026-01-13 16:17:22 +03:00
parent 349aebcf1e
commit bd235f4100
3 changed files with 13 additions and 3 deletions
+1 -2
View File
@@ -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 .",
+11
View File
@@ -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
View File
@@ -1,4 +1,4 @@
import * as jwt from "jsonwebtoken";
import jwt from "jsonwebtoken";
import { env } from "../config/env.js";
export interface JwtPayload {