e8d9b1fd42
Add complete token system with Plex/Tautulli/Overseer integration: - Anchor program for SPL token mint/burn/transfer - Express backend with OAuth, webhooks, Solana integration - Next.js frontend with dashboard, admin panel, wallet management - Docker deployment for 172.20.1.0/24 infrastructure - Production configs with SSL, Nginx, health monitoring Tautulli webhooks auto-mint on watch events. Overseer integration burns for content requests.
33 lines
756 B
TypeScript
33 lines
756 B
TypeScript
import { Request, Response, NextFunction } from 'express';
|
|
|
|
export interface ApiError extends Error {
|
|
statusCode?: number;
|
|
code?: string;
|
|
}
|
|
|
|
export const errorHandler = (
|
|
err: ApiError,
|
|
_req: Request,
|
|
res: Response,
|
|
_next: NextFunction
|
|
) => {
|
|
console.error('Error:', err);
|
|
|
|
const statusCode = err.statusCode || 500;
|
|
const message = err.message || 'Internal Server Error';
|
|
|
|
res.status(statusCode).json({
|
|
error: {
|
|
message,
|
|
code: err.code || 'INTERNAL_ERROR',
|
|
...(process.env.NODE_ENV === 'development' && { stack: err.stack })
|
|
}
|
|
});
|
|
};
|
|
|
|
export const asyncHandler = (fn: Function) => {
|
|
return (req: Request, res: Response, next: NextFunction) => {
|
|
Promise.resolve(fn(req, res, next)).catch(next);
|
|
};
|
|
};
|