feat(backend): add fastify api, auth, prisma schema and jobs

This commit is contained in:
Anton
2026-04-23 16:04:44 +03:00
parent 5f6a551b6c
commit 2972090c48
34 changed files with 1313 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
export class HttpError extends Error {
readonly statusCode: number;
readonly code: string;
readonly details?: unknown;
constructor(statusCode: number, code: string, message: string, details?: unknown) {
super(message);
this.name = 'HttpError';
this.statusCode = statusCode;
this.code = code;
this.details = details;
}
}
export class InvalidCredentialsError extends HttpError {
constructor() {
super(401, 'INVALID_CREDENTIALS', 'Invalid username or password');
}
}
export class UnauthorizedError extends HttpError {
constructor(message = 'Not authenticated') {
super(401, 'UNAUTHORIZED', message);
}
}
export class NotFoundError extends HttpError {
constructor(what = 'Resource') {
super(404, 'NOT_FOUND', `${what} not found`);
}
}
export class ConflictError extends HttpError {
constructor(message: string) {
super(409, 'CONFLICT', message);
}
}
export class ValidationError extends HttpError {
constructor(message: string, details?: unknown) {
super(400, 'VALIDATION', message, details);
}
}
export class ForbiddenError extends HttpError {
constructor(message = 'Forbidden') {
super(403, 'FORBIDDEN', message);
}
}