mirror of
https://github.com/mileswolfallen2/miles-web.git
synced 2026-12-06 16:43:55 +00:00
Add comprehensive test suite for application functionality
- Implement tests for HTTP API endpoints, ensuring correct responses and security headers. - Create configuration tests to validate loading of defaults and environment overrides. - Add tests for FEDL service to verify data handling and snapshot functionality. - Introduce GitHub service tests to check API data normalization and caching behavior. - Develop monitor service tests for network checks and uptime calculations. - Implement persistence tests to ensure database migrations are idempotent and data persists across restarts. - Add vault service tests for session management and brute-force protection mechanisms. - Include helper functions for test context creation and JSON response handling.
This commit is contained in:
1 parent
84b7a7e302
commit
c250653961
55 files changed
+8174
-226
No files matched your search
@@ -0,0 +1,23 @@
|
||||
export class AppError extends Error {
|
||||
constructor(status, code, message, details, expose = status < 500) {
|
||||
super(message);
|
||||
this.name = 'AppError';
|
||||
this.status = status;
|
||||
this.code = code;
|
||||
this.details = details;
|
||||
this.expose = expose;
|
||||
}
|
||||
}
|
||||
|
||||
export const badRequest = (message = 'Invalid request', details) =>
|
||||
new AppError(400, 'bad_request', message, details);
|
||||
export const unauthorized = (message = 'Unauthorized') =>
|
||||
new AppError(401, 'unauthorized', message);
|
||||
export const forbidden = (message = 'Forbidden') =>
|
||||
new AppError(403, 'forbidden', message);
|
||||
export const notFound = (message = 'Not found') =>
|
||||
new AppError(404, 'not_found', message);
|
||||
export const tooManyRequests = (message = 'Too many requests', retryAfterMs) =>
|
||||
new AppError(429, 'rate_limited', message, { retryAfterMs });
|
||||
export const unavailable = (message = 'Service unavailable') =>
|
||||
new AppError(503, 'unavailable', message);
|
||||
Reference in new issue
Block a user