feat: initial project scaffold
- React 19 + Vite + TailwindCSS frontend - Express + TypeScript backend API - PostgreSQL schema and migrations - Docker Compose orchestration - Drone CI/CD pipeline - Pages: Dashboard, Servers, Containers, Services, Logs, Metrics, Settings
This commit is contained in:
18
backend/src/middleware/errorHandler.ts
Normal file
18
backend/src/middleware/errorHandler.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Request, Response, NextFunction } from 'express';
|
||||
|
||||
export const errorHandler = (
|
||||
err: Error,
|
||||
req: Request,
|
||||
res: Response,
|
||||
next: NextFunction
|
||||
) => {
|
||||
console.error('Error:', err);
|
||||
|
||||
const statusCode = res.statusCode !== 200 ? res.statusCode : 500;
|
||||
|
||||
res.status(statusCode).json({
|
||||
error: err.message,
|
||||
stack: process.env.NODE_ENV === 'production' ? '🥞' : err.stack,
|
||||
timestamp: new Date().toISOString()
|
||||
});
|
||||
};
|
||||
10
backend/src/middleware/notFound.ts
Normal file
10
backend/src/middleware/notFound.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Request, Response, NextFunction } from 'express';
|
||||
|
||||
export const notFound = (req: Request, res: Response, next: NextFunction) => {
|
||||
res.status(404).json({
|
||||
error: 'Not Found',
|
||||
path: req.originalUrl,
|
||||
method: req.method,
|
||||
timestamp: new Date().toISOString()
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user