- Introduced a comprehensive backend API using TypeScript, Fastify, and PostgreSQL. - Added essential files including architecture documentation, environment configuration, and Docker setup. - Implemented RESTful routes for managing assets, liabilities, clients, invoices, and cashflow. - Established a robust database schema with Prisma for data management. - Integrated middleware for authentication and error handling. - Created service and repository layers to adhere to SOLID principles and clean architecture. - Included example environment variables for development, staging, and production setups.
39 lines
758 B
TypeScript
39 lines
758 B
TypeScript
/**
|
|
* Custom error classes
|
|
* Implements Open/Closed Principle: Extensible for new error types
|
|
*/
|
|
|
|
export abstract class AppError extends Error {
|
|
abstract statusCode: number;
|
|
|
|
constructor(message: string) {
|
|
super(message);
|
|
this.name = this.constructor.name;
|
|
Error.captureStackTrace(this, this.constructor);
|
|
}
|
|
}
|
|
|
|
export class NotFoundError extends AppError {
|
|
statusCode = 404;
|
|
}
|
|
|
|
export class ValidationError extends AppError {
|
|
statusCode = 400;
|
|
}
|
|
|
|
export class UnauthorizedError extends AppError {
|
|
statusCode = 401;
|
|
}
|
|
|
|
export class ForbiddenError extends AppError {
|
|
statusCode = 403;
|
|
}
|
|
|
|
export class ConflictError extends AppError {
|
|
statusCode = 409;
|
|
}
|
|
|
|
export class InternalServerError extends AppError {
|
|
statusCode = 500;
|
|
}
|