@riktajs/core 0.4.5 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/dist/core/application.d.ts +0 -29
  2. package/dist/core/application.js +0 -112
  3. package/dist/core/config/abstract-config-provider.d.ts +0 -134
  4. package/dist/core/config/abstract-config-provider.js +0 -124
  5. package/dist/core/config/env-loader.d.ts +0 -24
  6. package/dist/core/config/env-loader.js +0 -30
  7. package/dist/core/config/index.d.ts +0 -1
  8. package/dist/core/config/index.js +0 -1
  9. package/dist/core/constants.d.ts +0 -78
  10. package/dist/core/constants.js +0 -85
  11. package/dist/core/container/container.d.ts +0 -72
  12. package/dist/core/container/container.js +0 -102
  13. package/dist/core/container/index.d.ts +0 -1
  14. package/dist/core/container/index.js +0 -1
  15. package/dist/core/container/injection-token.d.ts +0 -29
  16. package/dist/core/container/injection-token.js +0 -22
  17. package/dist/core/decorators/autowired.decorator.d.ts +0 -62
  18. package/dist/core/decorators/autowired.decorator.js +0 -63
  19. package/dist/core/decorators/config-property.decorator.d.ts +0 -120
  20. package/dist/core/decorators/config-property.decorator.js +0 -140
  21. package/dist/core/decorators/controller.decorator.d.ts +0 -28
  22. package/dist/core/decorators/controller.decorator.js +0 -29
  23. package/dist/core/decorators/index.d.ts +0 -1
  24. package/dist/core/decorators/index.js +0 -2
  25. package/dist/core/decorators/injectable.decorator.d.ts +0 -23
  26. package/dist/core/decorators/injectable.decorator.js +0 -26
  27. package/dist/core/decorators/param.decorator.d.ts +0 -113
  28. package/dist/core/decorators/param.decorator.js +0 -126
  29. package/dist/core/decorators/provider.decorator.d.ts +0 -96
  30. package/dist/core/decorators/provider.decorator.js +0 -113
  31. package/dist/core/decorators/route.decorator.d.ts +0 -44
  32. package/dist/core/decorators/route.decorator.js +0 -51
  33. package/dist/core/discovery.d.ts +0 -33
  34. package/dist/core/discovery.js +4 -74
  35. package/dist/core/exceptions/catch.decorator.d.ts +0 -63
  36. package/dist/core/exceptions/catch.decorator.js +0 -59
  37. package/dist/core/exceptions/config.exceptions.d.ts +0 -12
  38. package/dist/core/exceptions/config.exceptions.js +0 -12
  39. package/dist/core/exceptions/exception-filter.d.ts +0 -96
  40. package/dist/core/exceptions/exception-filter.js +0 -53
  41. package/dist/core/exceptions/exceptions.d.ts +0 -157
  42. package/dist/core/exceptions/exceptions.js +0 -163
  43. package/dist/core/exceptions/http-exception.d.ts +0 -55
  44. package/dist/core/exceptions/http-exception.js +0 -40
  45. package/dist/core/exceptions/index.d.ts +0 -1
  46. package/dist/core/exceptions/index.js +0 -9
  47. package/dist/core/exceptions/validation.exception.d.ts +0 -41
  48. package/dist/core/exceptions/validation.exception.js +0 -34
  49. package/dist/core/guards/can-activate.interface.d.ts +0 -73
  50. package/dist/core/guards/can-activate.interface.js +0 -1
  51. package/dist/core/guards/execution-context.d.ts +0 -51
  52. package/dist/core/guards/execution-context.js +0 -6
  53. package/dist/core/guards/index.d.ts +0 -1
  54. package/dist/core/guards/index.js +0 -2
  55. package/dist/core/guards/use-guards.decorator.d.ts +0 -76
  56. package/dist/core/guards/use-guards.decorator.js +0 -78
  57. package/dist/core/index.d.ts +0 -1
  58. package/dist/core/index.js +0 -5
  59. package/dist/core/lifecycle/event-bus.d.ts +0 -44
  60. package/dist/core/lifecycle/event-bus.js +0 -30
  61. package/dist/core/lifecycle/index.d.ts +0 -1
  62. package/dist/core/lifecycle/index.js +0 -2
  63. package/dist/core/lifecycle/interfaces.d.ts +0 -91
  64. package/dist/core/lifecycle/interfaces.js +0 -8
  65. package/dist/core/lifecycle/on.decorator.d.ts +0 -51
  66. package/dist/core/lifecycle/on.decorator.js +0 -48
  67. package/dist/core/metadata.d.ts +0 -46
  68. package/dist/core/metadata.js +0 -71
  69. package/dist/core/registry.d.ts +0 -77
  70. package/dist/core/registry.js +0 -77
  71. package/dist/core/router/router.d.ts +0 -41
  72. package/dist/core/router/router.js +0 -76
  73. package/dist/core/types.d.ts +0 -109
  74. package/dist/core/types.js +0 -1
  75. package/dist/index.d.ts +0 -42
  76. package/dist/index.js +0 -44
  77. package/package.json +1 -1
  78. package/dist/core/application.d.ts.map +0 -1
  79. package/dist/core/application.js.map +0 -1
  80. package/dist/core/config/abstract-config-provider.d.ts.map +0 -1
  81. package/dist/core/config/abstract-config-provider.js.map +0 -1
  82. package/dist/core/config/env-loader.d.ts.map +0 -1
  83. package/dist/core/config/env-loader.js.map +0 -1
  84. package/dist/core/config/index.d.ts.map +0 -1
  85. package/dist/core/config/index.js.map +0 -1
  86. package/dist/core/constants.d.ts.map +0 -1
  87. package/dist/core/constants.js.map +0 -1
  88. package/dist/core/container/container.d.ts.map +0 -1
  89. package/dist/core/container/container.js.map +0 -1
  90. package/dist/core/container/index.d.ts.map +0 -1
  91. package/dist/core/container/index.js.map +0 -1
  92. package/dist/core/container/injection-token.d.ts.map +0 -1
  93. package/dist/core/container/injection-token.js.map +0 -1
  94. package/dist/core/decorators/autowired.decorator.d.ts.map +0 -1
  95. package/dist/core/decorators/autowired.decorator.js.map +0 -1
  96. package/dist/core/decorators/config-property.decorator.d.ts.map +0 -1
  97. package/dist/core/decorators/config-property.decorator.js.map +0 -1
  98. package/dist/core/decorators/controller.decorator.d.ts.map +0 -1
  99. package/dist/core/decorators/controller.decorator.js.map +0 -1
  100. package/dist/core/decorators/index.d.ts.map +0 -1
  101. package/dist/core/decorators/index.js.map +0 -1
  102. package/dist/core/decorators/injectable.decorator.d.ts.map +0 -1
  103. package/dist/core/decorators/injectable.decorator.js.map +0 -1
  104. package/dist/core/decorators/param.decorator.d.ts.map +0 -1
  105. package/dist/core/decorators/param.decorator.js.map +0 -1
  106. package/dist/core/decorators/provider.decorator.d.ts.map +0 -1
  107. package/dist/core/decorators/provider.decorator.js.map +0 -1
  108. package/dist/core/decorators/route.decorator.d.ts.map +0 -1
  109. package/dist/core/decorators/route.decorator.js.map +0 -1
  110. package/dist/core/discovery.d.ts.map +0 -1
  111. package/dist/core/discovery.js.map +0 -1
  112. package/dist/core/exceptions/catch.decorator.d.ts.map +0 -1
  113. package/dist/core/exceptions/catch.decorator.js.map +0 -1
  114. package/dist/core/exceptions/config.exceptions.d.ts.map +0 -1
  115. package/dist/core/exceptions/config.exceptions.js.map +0 -1
  116. package/dist/core/exceptions/exception-filter.d.ts.map +0 -1
  117. package/dist/core/exceptions/exception-filter.js.map +0 -1
  118. package/dist/core/exceptions/exceptions.d.ts.map +0 -1
  119. package/dist/core/exceptions/exceptions.js.map +0 -1
  120. package/dist/core/exceptions/http-exception.d.ts.map +0 -1
  121. package/dist/core/exceptions/http-exception.js.map +0 -1
  122. package/dist/core/exceptions/index.d.ts.map +0 -1
  123. package/dist/core/exceptions/index.js.map +0 -1
  124. package/dist/core/exceptions/validation.exception.d.ts.map +0 -1
  125. package/dist/core/exceptions/validation.exception.js.map +0 -1
  126. package/dist/core/guards/can-activate.interface.d.ts.map +0 -1
  127. package/dist/core/guards/can-activate.interface.js.map +0 -1
  128. package/dist/core/guards/execution-context.d.ts.map +0 -1
  129. package/dist/core/guards/execution-context.js.map +0 -1
  130. package/dist/core/guards/index.d.ts.map +0 -1
  131. package/dist/core/guards/index.js.map +0 -1
  132. package/dist/core/guards/use-guards.decorator.d.ts.map +0 -1
  133. package/dist/core/guards/use-guards.decorator.js.map +0 -1
  134. package/dist/core/index.d.ts.map +0 -1
  135. package/dist/core/index.js.map +0 -1
  136. package/dist/core/lifecycle/event-bus.d.ts.map +0 -1
  137. package/dist/core/lifecycle/event-bus.js.map +0 -1
  138. package/dist/core/lifecycle/index.d.ts.map +0 -1
  139. package/dist/core/lifecycle/index.js.map +0 -1
  140. package/dist/core/lifecycle/interfaces.d.ts.map +0 -1
  141. package/dist/core/lifecycle/interfaces.js.map +0 -1
  142. package/dist/core/lifecycle/on.decorator.d.ts.map +0 -1
  143. package/dist/core/lifecycle/on.decorator.js.map +0 -1
  144. package/dist/core/metadata.d.ts.map +0 -1
  145. package/dist/core/metadata.js.map +0 -1
  146. package/dist/core/registry.d.ts.map +0 -1
  147. package/dist/core/registry.js.map +0 -1
  148. package/dist/core/router/router.d.ts.map +0 -1
  149. package/dist/core/router/router.js.map +0 -1
  150. package/dist/core/types.d.ts.map +0 -1
  151. package/dist/core/types.js.map +0 -1
  152. package/dist/index.d.ts.map +0 -1
  153. package/dist/index.js.map +0 -1
@@ -3,30 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GlobalExceptionFilter = void 0;
4
4
  exports.createExceptionHandler = createExceptionHandler;
5
5
  const http_exception_1 = require("./http-exception");
6
- /**
7
- * Global Exception Filter
8
- *
9
- * Default exception handler that catches all errors and returns
10
- * a standardized JSON response.
11
- *
12
- * Features:
13
- * - Handles HttpException with proper status codes
14
- * - Handles Fastify validation errors
15
- * - Handles unknown errors as 500 Internal Server Error
16
- * - Includes stack traces in development mode
17
- *
18
- * @example
19
- * ```typescript
20
- * // The filter is automatically registered by Rikta
21
- * // But you can customize behavior via options:
22
- * const app = await Rikta.create({
23
- * exceptionFilter: {
24
- * includeStack: process.env.NODE_ENV !== 'production',
25
- * logErrors: true
26
- * }
27
- * });
28
- * ```
29
- */
30
6
  class GlobalExceptionFilter {
31
7
  includeStack;
32
8
  logErrors;
@@ -34,26 +10,16 @@ class GlobalExceptionFilter {
34
10
  this.includeStack = options.includeStack ?? process.env.NODE_ENV !== 'production';
35
11
  this.logErrors = options.logErrors ?? true;
36
12
  }
37
- /**
38
- * Handle any exception and send standardized response
39
- */
40
13
  catch(exception, context) {
41
14
  const { request, reply, path, method } = context;
42
15
  const requestId = request.id ?? undefined;
43
- // Log the error
44
16
  if (this.logErrors) {
45
17
  this.logError(exception, method, path, requestId);
46
18
  }
47
- // Build error response
48
19
  const response = this.buildResponse(exception, path, requestId);
49
- // Send response
50
20
  reply.status(response.statusCode).send(response);
51
21
  }
52
- /**
53
- * Build standardized error response
54
- */
55
22
  buildResponse(exception, path, requestId) {
56
- // Handle HttpException
57
23
  if (exception instanceof http_exception_1.HttpException) {
58
24
  const httpResponse = exception.getResponse();
59
25
  return {
@@ -68,7 +34,6 @@ class GlobalExceptionFilter {
68
34
  ...(this.includeStack ? { stack: exception.stack } : {}),
69
35
  };
70
36
  }
71
- // Handle Fastify validation errors
72
37
  if (this.isFastifyValidationError(exception)) {
73
38
  return {
74
39
  statusCode: 400,
@@ -81,7 +46,6 @@ class GlobalExceptionFilter {
81
46
  ...(this.includeStack && { stack: exception.stack }),
82
47
  };
83
48
  }
84
- // Handle Fastify errors with statusCode
85
49
  if (this.isFastifyError(exception)) {
86
50
  const fastifyError = exception;
87
51
  return {
@@ -94,7 +58,6 @@ class GlobalExceptionFilter {
94
58
  ...(this.includeStack && { stack: exception.stack }),
95
59
  };
96
60
  }
97
- // Handle unknown errors as 500
98
61
  return {
99
62
  statusCode: 500,
100
63
  message: this.includeStack ? exception.message : 'Internal Server Error',
@@ -105,21 +68,12 @@ class GlobalExceptionFilter {
105
68
  ...(this.includeStack && { stack: exception.stack }),
106
69
  };
107
70
  }
108
- /**
109
- * Check if error is a Fastify validation error
110
- */
111
71
  isFastifyValidationError(error) {
112
72
  return 'validation' in error && Array.isArray(error.validation);
113
73
  }
114
- /**
115
- * Check if error is a Fastify error with statusCode
116
- */
117
74
  isFastifyError(error) {
118
75
  return 'statusCode' in error;
119
76
  }
120
- /**
121
- * Log error to console
122
- */
123
77
  logError(exception, method, path, requestId) {
124
78
  const timestamp = new Date().toISOString();
125
79
  const status = exception instanceof http_exception_1.HttpException
@@ -128,16 +82,12 @@ class GlobalExceptionFilter {
128
82
  const prefix = status >= 500 ? '❌' : '⚠️';
129
83
  const reqIdStr = requestId ? ` [${requestId}]` : '';
130
84
  console.error(`${prefix} [${timestamp}]${reqIdStr} ${method} ${path} - ${status} ${exception.message}`);
131
- // Log stack trace for 5xx errors in development
132
85
  if (status >= 500 && this.includeStack && exception.stack) {
133
86
  console.error(exception.stack);
134
87
  }
135
88
  }
136
89
  }
137
90
  exports.GlobalExceptionFilter = GlobalExceptionFilter;
138
- /**
139
- * Create exception handler function for Fastify
140
- */
141
91
  function createExceptionHandler(filter, customFilters = new Map()) {
142
92
  return async (error, request, reply) => {
143
93
  const context = {
@@ -148,14 +98,11 @@ function createExceptionHandler(filter, customFilters = new Map()) {
148
98
  method: request.method,
149
99
  requestId: request.id,
150
100
  };
151
- // Try to find a custom filter for this exception type
152
101
  for (const [ExceptionType, customFilter] of customFilters) {
153
102
  if (error instanceof ExceptionType) {
154
103
  return customFilter.catch(error, context);
155
104
  }
156
105
  }
157
- // Use global filter
158
106
  return filter.catch(error, context);
159
107
  };
160
108
  }
161
- //# sourceMappingURL=exception-filter.js.map
@@ -1,212 +1,55 @@
1
1
  import { HttpException, HttpExceptionBody } from './http-exception';
2
- /**
3
- * 400 Bad Request
4
- *
5
- * The server cannot process the request due to client error.
6
- *
7
- * @example
8
- * ```typescript
9
- * throw new BadRequestException('Invalid input data');
10
- *
11
- * throw new BadRequestException({
12
- * message: 'Validation failed',
13
- * details: { email: 'Invalid format' }
14
- * });
15
- * ```
16
- */
17
2
  export declare class BadRequestException extends HttpException {
18
3
  constructor(response?: string | HttpExceptionBody);
19
4
  }
20
- /**
21
- * 401 Unauthorized
22
- *
23
- * Authentication is required and has failed or not been provided.
24
- *
25
- * @example
26
- * ```typescript
27
- * throw new UnauthorizedException('Invalid credentials');
28
- * throw new UnauthorizedException('Token expired');
29
- * ```
30
- */
31
5
  export declare class UnauthorizedException extends HttpException {
32
6
  constructor(response?: string | HttpExceptionBody);
33
7
  }
34
- /**
35
- * 403 Forbidden
36
- *
37
- * The server understood the request but refuses to authorize it.
38
- *
39
- * @example
40
- * ```typescript
41
- * throw new ForbiddenException('Access denied');
42
- * throw new ForbiddenException('Insufficient permissions');
43
- * ```
44
- */
45
8
  export declare class ForbiddenException extends HttpException {
46
9
  constructor(response?: string | HttpExceptionBody);
47
10
  }
48
- /**
49
- * 404 Not Found
50
- *
51
- * The requested resource could not be found.
52
- *
53
- * @example
54
- * ```typescript
55
- * throw new NotFoundException('User not found');
56
- * throw new NotFoundException(`Resource ${id} not found`);
57
- * ```
58
- */
59
11
  export declare class NotFoundException extends HttpException {
60
12
  constructor(response?: string | HttpExceptionBody);
61
13
  }
62
- /**
63
- * 405 Method Not Allowed
64
- *
65
- * The request method is not supported for the requested resource.
66
- *
67
- * @example
68
- * ```typescript
69
- * throw new MethodNotAllowedException('POST not allowed on this endpoint');
70
- * ```
71
- */
72
14
  export declare class MethodNotAllowedException extends HttpException {
73
15
  constructor(response?: string | HttpExceptionBody);
74
16
  }
75
- /**
76
- * 406 Not Acceptable
77
- *
78
- * The requested resource is not capable of generating content acceptable
79
- * according to the Accept headers sent in the request.
80
- */
81
17
  export declare class NotAcceptableException extends HttpException {
82
18
  constructor(response?: string | HttpExceptionBody);
83
19
  }
84
- /**
85
- * 408 Request Timeout
86
- *
87
- * The server timed out waiting for the request.
88
- */
89
20
  export declare class RequestTimeoutException extends HttpException {
90
21
  constructor(response?: string | HttpExceptionBody);
91
22
  }
92
- /**
93
- * 409 Conflict
94
- *
95
- * The request conflicts with the current state of the server.
96
- *
97
- * @example
98
- * ```typescript
99
- * throw new ConflictException('Email already exists');
100
- * throw new ConflictException('Version conflict');
101
- * ```
102
- */
103
23
  export declare class ConflictException extends HttpException {
104
24
  constructor(response?: string | HttpExceptionBody);
105
25
  }
106
- /**
107
- * 410 Gone
108
- *
109
- * The resource is no longer available and will not be available again.
110
- */
111
26
  export declare class GoneException extends HttpException {
112
27
  constructor(response?: string | HttpExceptionBody);
113
28
  }
114
- /**
115
- * 413 Payload Too Large
116
- *
117
- * The request entity is larger than limits defined by the server.
118
- */
119
29
  export declare class PayloadTooLargeException extends HttpException {
120
30
  constructor(response?: string | HttpExceptionBody);
121
31
  }
122
- /**
123
- * 415 Unsupported Media Type
124
- *
125
- * The media format of the requested data is not supported by the server.
126
- */
127
32
  export declare class UnsupportedMediaTypeException extends HttpException {
128
33
  constructor(response?: string | HttpExceptionBody);
129
34
  }
130
- /**
131
- * 422 Unprocessable Entity
132
- *
133
- * The server understands the content type, but was unable to process the contained instructions.
134
- *
135
- * @example
136
- * ```typescript
137
- * throw new UnprocessableEntityException({
138
- * message: 'Validation failed',
139
- * details: [
140
- * { field: 'email', message: 'Invalid email format' },
141
- * { field: 'age', message: 'Must be a positive number' }
142
- * ]
143
- * });
144
- * ```
145
- */
146
35
  export declare class UnprocessableEntityException extends HttpException {
147
36
  constructor(response?: string | HttpExceptionBody);
148
37
  }
149
- /**
150
- * 429 Too Many Requests
151
- *
152
- * The user has sent too many requests in a given amount of time.
153
- *
154
- * @example
155
- * ```typescript
156
- * throw new TooManyRequestsException('Rate limit exceeded. Try again in 60 seconds.');
157
- * ```
158
- */
159
38
  export declare class TooManyRequestsException extends HttpException {
160
39
  constructor(response?: string | HttpExceptionBody);
161
40
  }
162
- /**
163
- * 500 Internal Server Error
164
- *
165
- * A generic server error occurred.
166
- *
167
- * @example
168
- * ```typescript
169
- * throw new InternalServerErrorException('An unexpected error occurred');
170
- * ```
171
- */
172
41
  export declare class InternalServerErrorException extends HttpException {
173
42
  constructor(response?: string | HttpExceptionBody);
174
43
  }
175
- /**
176
- * 501 Not Implemented
177
- *
178
- * The server does not support the functionality required to fulfill the request.
179
- */
180
44
  export declare class NotImplementedException extends HttpException {
181
45
  constructor(response?: string | HttpExceptionBody);
182
46
  }
183
- /**
184
- * 502 Bad Gateway
185
- *
186
- * The server received an invalid response from an upstream server.
187
- */
188
47
  export declare class BadGatewayException extends HttpException {
189
48
  constructor(response?: string | HttpExceptionBody);
190
49
  }
191
- /**
192
- * 503 Service Unavailable
193
- *
194
- * The server is not ready to handle the request.
195
- *
196
- * @example
197
- * ```typescript
198
- * throw new ServiceUnavailableException('Service is under maintenance');
199
- * ```
200
- */
201
50
  export declare class ServiceUnavailableException extends HttpException {
202
51
  constructor(response?: string | HttpExceptionBody);
203
52
  }
204
- /**
205
- * 504 Gateway Timeout
206
- *
207
- * The server did not receive a timely response from an upstream server.
208
- */
209
53
  export declare class GatewayTimeoutException extends HttpException {
210
54
  constructor(response?: string | HttpExceptionBody);
211
55
  }
212
- //# sourceMappingURL=exceptions.d.ts.map
@@ -2,274 +2,111 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GatewayTimeoutException = exports.ServiceUnavailableException = exports.BadGatewayException = exports.NotImplementedException = exports.InternalServerErrorException = exports.TooManyRequestsException = exports.UnprocessableEntityException = exports.UnsupportedMediaTypeException = exports.PayloadTooLargeException = exports.GoneException = exports.ConflictException = exports.RequestTimeoutException = exports.NotAcceptableException = exports.MethodNotAllowedException = exports.NotFoundException = exports.ForbiddenException = exports.UnauthorizedException = exports.BadRequestException = void 0;
4
4
  const http_exception_1 = require("./http-exception");
5
- // ============================================================================
6
- // 4xx Client Errors
7
- // ============================================================================
8
- /**
9
- * 400 Bad Request
10
- *
11
- * The server cannot process the request due to client error.
12
- *
13
- * @example
14
- * ```typescript
15
- * throw new BadRequestException('Invalid input data');
16
- *
17
- * throw new BadRequestException({
18
- * message: 'Validation failed',
19
- * details: { email: 'Invalid format' }
20
- * });
21
- * ```
22
- */
23
5
  class BadRequestException extends http_exception_1.HttpException {
24
6
  constructor(response = 'Bad Request') {
25
7
  super(response, 400);
26
8
  }
27
9
  }
28
10
  exports.BadRequestException = BadRequestException;
29
- /**
30
- * 401 Unauthorized
31
- *
32
- * Authentication is required and has failed or not been provided.
33
- *
34
- * @example
35
- * ```typescript
36
- * throw new UnauthorizedException('Invalid credentials');
37
- * throw new UnauthorizedException('Token expired');
38
- * ```
39
- */
40
11
  class UnauthorizedException extends http_exception_1.HttpException {
41
12
  constructor(response = 'Unauthorized') {
42
13
  super(response, 401);
43
14
  }
44
15
  }
45
16
  exports.UnauthorizedException = UnauthorizedException;
46
- /**
47
- * 403 Forbidden
48
- *
49
- * The server understood the request but refuses to authorize it.
50
- *
51
- * @example
52
- * ```typescript
53
- * throw new ForbiddenException('Access denied');
54
- * throw new ForbiddenException('Insufficient permissions');
55
- * ```
56
- */
57
17
  class ForbiddenException extends http_exception_1.HttpException {
58
18
  constructor(response = 'Forbidden') {
59
19
  super(response, 403);
60
20
  }
61
21
  }
62
22
  exports.ForbiddenException = ForbiddenException;
63
- /**
64
- * 404 Not Found
65
- *
66
- * The requested resource could not be found.
67
- *
68
- * @example
69
- * ```typescript
70
- * throw new NotFoundException('User not found');
71
- * throw new NotFoundException(`Resource ${id} not found`);
72
- * ```
73
- */
74
23
  class NotFoundException extends http_exception_1.HttpException {
75
24
  constructor(response = 'Not Found') {
76
25
  super(response, 404);
77
26
  }
78
27
  }
79
28
  exports.NotFoundException = NotFoundException;
80
- /**
81
- * 405 Method Not Allowed
82
- *
83
- * The request method is not supported for the requested resource.
84
- *
85
- * @example
86
- * ```typescript
87
- * throw new MethodNotAllowedException('POST not allowed on this endpoint');
88
- * ```
89
- */
90
29
  class MethodNotAllowedException extends http_exception_1.HttpException {
91
30
  constructor(response = 'Method Not Allowed') {
92
31
  super(response, 405);
93
32
  }
94
33
  }
95
34
  exports.MethodNotAllowedException = MethodNotAllowedException;
96
- /**
97
- * 406 Not Acceptable
98
- *
99
- * The requested resource is not capable of generating content acceptable
100
- * according to the Accept headers sent in the request.
101
- */
102
35
  class NotAcceptableException extends http_exception_1.HttpException {
103
36
  constructor(response = 'Not Acceptable') {
104
37
  super(response, 406);
105
38
  }
106
39
  }
107
40
  exports.NotAcceptableException = NotAcceptableException;
108
- /**
109
- * 408 Request Timeout
110
- *
111
- * The server timed out waiting for the request.
112
- */
113
41
  class RequestTimeoutException extends http_exception_1.HttpException {
114
42
  constructor(response = 'Request Timeout') {
115
43
  super(response, 408);
116
44
  }
117
45
  }
118
46
  exports.RequestTimeoutException = RequestTimeoutException;
119
- /**
120
- * 409 Conflict
121
- *
122
- * The request conflicts with the current state of the server.
123
- *
124
- * @example
125
- * ```typescript
126
- * throw new ConflictException('Email already exists');
127
- * throw new ConflictException('Version conflict');
128
- * ```
129
- */
130
47
  class ConflictException extends http_exception_1.HttpException {
131
48
  constructor(response = 'Conflict') {
132
49
  super(response, 409);
133
50
  }
134
51
  }
135
52
  exports.ConflictException = ConflictException;
136
- /**
137
- * 410 Gone
138
- *
139
- * The resource is no longer available and will not be available again.
140
- */
141
53
  class GoneException extends http_exception_1.HttpException {
142
54
  constructor(response = 'Gone') {
143
55
  super(response, 410);
144
56
  }
145
57
  }
146
58
  exports.GoneException = GoneException;
147
- /**
148
- * 413 Payload Too Large
149
- *
150
- * The request entity is larger than limits defined by the server.
151
- */
152
59
  class PayloadTooLargeException extends http_exception_1.HttpException {
153
60
  constructor(response = 'Payload Too Large') {
154
61
  super(response, 413);
155
62
  }
156
63
  }
157
64
  exports.PayloadTooLargeException = PayloadTooLargeException;
158
- /**
159
- * 415 Unsupported Media Type
160
- *
161
- * The media format of the requested data is not supported by the server.
162
- */
163
65
  class UnsupportedMediaTypeException extends http_exception_1.HttpException {
164
66
  constructor(response = 'Unsupported Media Type') {
165
67
  super(response, 415);
166
68
  }
167
69
  }
168
70
  exports.UnsupportedMediaTypeException = UnsupportedMediaTypeException;
169
- /**
170
- * 422 Unprocessable Entity
171
- *
172
- * The server understands the content type, but was unable to process the contained instructions.
173
- *
174
- * @example
175
- * ```typescript
176
- * throw new UnprocessableEntityException({
177
- * message: 'Validation failed',
178
- * details: [
179
- * { field: 'email', message: 'Invalid email format' },
180
- * { field: 'age', message: 'Must be a positive number' }
181
- * ]
182
- * });
183
- * ```
184
- */
185
71
  class UnprocessableEntityException extends http_exception_1.HttpException {
186
72
  constructor(response = 'Unprocessable Entity') {
187
73
  super(response, 422);
188
74
  }
189
75
  }
190
76
  exports.UnprocessableEntityException = UnprocessableEntityException;
191
- /**
192
- * 429 Too Many Requests
193
- *
194
- * The user has sent too many requests in a given amount of time.
195
- *
196
- * @example
197
- * ```typescript
198
- * throw new TooManyRequestsException('Rate limit exceeded. Try again in 60 seconds.');
199
- * ```
200
- */
201
77
  class TooManyRequestsException extends http_exception_1.HttpException {
202
78
  constructor(response = 'Too Many Requests') {
203
79
  super(response, 429);
204
80
  }
205
81
  }
206
82
  exports.TooManyRequestsException = TooManyRequestsException;
207
- // ============================================================================
208
- // 5xx Server Errors
209
- // ============================================================================
210
- /**
211
- * 500 Internal Server Error
212
- *
213
- * A generic server error occurred.
214
- *
215
- * @example
216
- * ```typescript
217
- * throw new InternalServerErrorException('An unexpected error occurred');
218
- * ```
219
- */
220
83
  class InternalServerErrorException extends http_exception_1.HttpException {
221
84
  constructor(response = 'Internal Server Error') {
222
85
  super(response, 500);
223
86
  }
224
87
  }
225
88
  exports.InternalServerErrorException = InternalServerErrorException;
226
- /**
227
- * 501 Not Implemented
228
- *
229
- * The server does not support the functionality required to fulfill the request.
230
- */
231
89
  class NotImplementedException extends http_exception_1.HttpException {
232
90
  constructor(response = 'Not Implemented') {
233
91
  super(response, 501);
234
92
  }
235
93
  }
236
94
  exports.NotImplementedException = NotImplementedException;
237
- /**
238
- * 502 Bad Gateway
239
- *
240
- * The server received an invalid response from an upstream server.
241
- */
242
95
  class BadGatewayException extends http_exception_1.HttpException {
243
96
  constructor(response = 'Bad Gateway') {
244
97
  super(response, 502);
245
98
  }
246
99
  }
247
100
  exports.BadGatewayException = BadGatewayException;
248
- /**
249
- * 503 Service Unavailable
250
- *
251
- * The server is not ready to handle the request.
252
- *
253
- * @example
254
- * ```typescript
255
- * throw new ServiceUnavailableException('Service is under maintenance');
256
- * ```
257
- */
258
101
  class ServiceUnavailableException extends http_exception_1.HttpException {
259
102
  constructor(response = 'Service Unavailable') {
260
103
  super(response, 503);
261
104
  }
262
105
  }
263
106
  exports.ServiceUnavailableException = ServiceUnavailableException;
264
- /**
265
- * 504 Gateway Timeout
266
- *
267
- * The server did not receive a timely response from an upstream server.
268
- */
269
107
  class GatewayTimeoutException extends http_exception_1.HttpException {
270
108
  constructor(response = 'Gateway Timeout') {
271
109
  super(response, 504);
272
110
  }
273
111
  }
274
112
  exports.GatewayTimeoutException = GatewayTimeoutException;
275
- //# sourceMappingURL=exceptions.js.map
@@ -1,79 +1,24 @@
1
- /**
2
- * HTTP Exception Base Class
3
- *
4
- * Base class for all HTTP exceptions in Rikta.
5
- * Provides a standard structure for error responses.
6
- *
7
- * @example
8
- * ```typescript
9
- * // Throw directly
10
- * throw new HttpException('Something went wrong', 500);
11
- *
12
- * // With additional details
13
- * throw new HttpException({
14
- * message: 'Validation failed',
15
- * error: 'Bad Request',
16
- * details: { field: 'email', reason: 'Invalid format' }
17
- * }, 400);
18
- * ```
19
- */
20
1
  export declare class HttpException extends Error {
21
- /**
22
- * HTTP status code
23
- */
24
2
  readonly statusCode: number;
25
- /**
26
- * Error response object
27
- */
28
3
  readonly response: HttpExceptionResponse;
29
- /**
30
- * Timestamp when the exception was created
31
- */
32
4
  readonly timestamp: string;
33
5
  constructor(response: string | HttpExceptionBody, statusCode?: number);
34
- /**
35
- * Get the response object for JSON serialization
36
- */
37
6
  getResponse(): HttpExceptionResponse;
38
- /**
39
- * Get the HTTP status code
40
- */
41
7
  getStatus(): number;
42
- /**
43
- * Get default error name for status code
44
- */
45
8
  private getDefaultError;
46
9
  }
47
- /**
48
- * Exception body structure for custom responses
49
- */
50
10
  export interface HttpExceptionBody {
51
- /** Error message */
52
11
  message: string;
53
- /** Error type/name (e.g., "Bad Request", "Validation Error") */
54
12
  error?: string;
55
- /** Additional error details */
56
13
  details?: unknown;
57
- /** Application-specific error code */
58
14
  code?: string;
59
15
  }
60
- /**
61
- * Standard HTTP exception response format
62
- */
63
16
  export interface HttpExceptionResponse {
64
- /** HTTP status code */
65
17
  statusCode: number;
66
- /** Error message */
67
18
  message: string;
68
- /** Error type/name */
69
19
  error: string;
70
- /** ISO timestamp */
71
20
  timestamp: string;
72
- /** Additional error details (optional) */
73
21
  details?: unknown;
74
- /** Application-specific error code (optional) */
75
22
  code?: string;
76
- /** Request path (added by filter) */
77
23
  path?: string;
78
24
  }
79
- //# sourceMappingURL=http-exception.d.ts.map