@riktajs/core 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +205 -0
- package/dist/core/application.d.ts +28 -0
- package/dist/core/application.d.ts.map +1 -0
- package/dist/core/application.js +321 -0
- package/dist/core/application.js.map +1 -0
- package/dist/core/constants.d.ts +70 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/constants.js +77 -0
- package/dist/core/constants.js.map +1 -0
- package/dist/core/container/container.d.ts +101 -0
- package/dist/core/container/container.d.ts.map +1 -0
- package/dist/core/container/container.js +327 -0
- package/dist/core/container/container.js.map +1 -0
- package/dist/core/container/index.d.ts +3 -0
- package/dist/core/container/index.d.ts.map +1 -0
- package/dist/core/container/index.js +19 -0
- package/dist/core/container/index.js.map +1 -0
- package/dist/core/container/injection-token.d.ts +58 -0
- package/dist/core/container/injection-token.d.ts.map +1 -0
- package/dist/core/container/injection-token.js +37 -0
- package/dist/core/container/injection-token.js.map +1 -0
- package/dist/core/decorators/autowired.decorator.d.ts +72 -0
- package/dist/core/decorators/autowired.decorator.d.ts.map +1 -0
- package/dist/core/decorators/autowired.decorator.js +143 -0
- package/dist/core/decorators/autowired.decorator.js.map +1 -0
- package/dist/core/decorators/controller.decorator.d.ts +33 -0
- package/dist/core/decorators/controller.decorator.d.ts.map +1 -0
- package/dist/core/decorators/controller.decorator.js +50 -0
- package/dist/core/decorators/controller.decorator.js.map +1 -0
- package/dist/core/decorators/index.d.ts +7 -0
- package/dist/core/decorators/index.d.ts.map +1 -0
- package/dist/core/decorators/index.js +24 -0
- package/dist/core/decorators/index.js.map +1 -0
- package/dist/core/decorators/injectable.decorator.d.ts +26 -0
- package/dist/core/decorators/injectable.decorator.d.ts.map +1 -0
- package/dist/core/decorators/injectable.decorator.js +40 -0
- package/dist/core/decorators/injectable.decorator.js.map +1 -0
- package/dist/core/decorators/param.decorator.d.ts +72 -0
- package/dist/core/decorators/param.decorator.d.ts.map +1 -0
- package/dist/core/decorators/param.decorator.js +88 -0
- package/dist/core/decorators/param.decorator.js.map +1 -0
- package/dist/core/decorators/provider.decorator.d.ts +64 -0
- package/dist/core/decorators/provider.decorator.d.ts.map +1 -0
- package/dist/core/decorators/provider.decorator.js +69 -0
- package/dist/core/decorators/provider.decorator.js.map +1 -0
- package/dist/core/decorators/route.decorator.d.ts +53 -0
- package/dist/core/decorators/route.decorator.d.ts.map +1 -0
- package/dist/core/decorators/route.decorator.js +85 -0
- package/dist/core/decorators/route.decorator.js.map +1 -0
- package/dist/core/discovery.d.ts +24 -0
- package/dist/core/discovery.d.ts.map +1 -0
- package/dist/core/discovery.js +168 -0
- package/dist/core/discovery.js.map +1 -0
- package/dist/core/exceptions/catch.decorator.d.ts +71 -0
- package/dist/core/exceptions/catch.decorator.d.ts.map +1 -0
- package/dist/core/exceptions/catch.decorator.js +77 -0
- package/dist/core/exceptions/catch.decorator.js.map +1 -0
- package/dist/core/exceptions/exception-filter.d.ts +134 -0
- package/dist/core/exceptions/exception-filter.d.ts.map +1 -0
- package/dist/core/exceptions/exception-filter.js +161 -0
- package/dist/core/exceptions/exception-filter.js.map +1 -0
- package/dist/core/exceptions/exceptions.d.ts +212 -0
- package/dist/core/exceptions/exceptions.d.ts.map +1 -0
- package/dist/core/exceptions/exceptions.js +275 -0
- package/dist/core/exceptions/exceptions.js.map +1 -0
- package/dist/core/exceptions/http-exception.d.ts +79 -0
- package/dist/core/exceptions/http-exception.d.ts.map +1 -0
- package/dist/core/exceptions/http-exception.js +106 -0
- package/dist/core/exceptions/http-exception.js.map +1 -0
- package/dist/core/exceptions/index.d.ts +5 -0
- package/dist/core/exceptions/index.d.ts.map +1 -0
- package/dist/core/exceptions/index.js +38 -0
- package/dist/core/exceptions/index.js.map +1 -0
- package/dist/core/index.d.ts +11 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +28 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/lifecycle/event-bus.d.ts +96 -0
- package/dist/core/lifecycle/event-bus.d.ts.map +1 -0
- package/dist/core/lifecycle/event-bus.js +91 -0
- package/dist/core/lifecycle/event-bus.js.map +1 -0
- package/dist/core/lifecycle/index.d.ts +4 -0
- package/dist/core/lifecycle/index.d.ts.map +1 -0
- package/dist/core/lifecycle/index.js +21 -0
- package/dist/core/lifecycle/index.js.map +1 -0
- package/dist/core/lifecycle/interfaces.d.ts +106 -0
- package/dist/core/lifecycle/interfaces.d.ts.map +1 -0
- package/dist/core/lifecycle/interfaces.js +10 -0
- package/dist/core/lifecycle/interfaces.js.map +1 -0
- package/dist/core/lifecycle/on.decorator.d.ts +62 -0
- package/dist/core/lifecycle/on.decorator.d.ts.map +1 -0
- package/dist/core/lifecycle/on.decorator.js +65 -0
- package/dist/core/lifecycle/on.decorator.js.map +1 -0
- package/dist/core/registry.d.ts +64 -0
- package/dist/core/registry.d.ts.map +1 -0
- package/dist/core/registry.js +91 -0
- package/dist/core/registry.js.map +1 -0
- package/dist/core/router/router.d.ts +39 -0
- package/dist/core/router/router.d.ts.map +1 -0
- package/dist/core/router/router.js +150 -0
- package/dist/core/router/router.js.map +1 -0
- package/dist/core/types.d.ts +161 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +3 -0
- package/dist/core/types.js.map +1 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +64 -0
- package/dist/index.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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
|
+
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
|
+
class BadRequestException extends http_exception_1.HttpException {
|
|
24
|
+
constructor(response = 'Bad Request') {
|
|
25
|
+
super(response, 400);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
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
|
+
class UnauthorizedException extends http_exception_1.HttpException {
|
|
41
|
+
constructor(response = 'Unauthorized') {
|
|
42
|
+
super(response, 401);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
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
|
+
class ForbiddenException extends http_exception_1.HttpException {
|
|
58
|
+
constructor(response = 'Forbidden') {
|
|
59
|
+
super(response, 403);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
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
|
+
class NotFoundException extends http_exception_1.HttpException {
|
|
75
|
+
constructor(response = 'Not Found') {
|
|
76
|
+
super(response, 404);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
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
|
+
class MethodNotAllowedException extends http_exception_1.HttpException {
|
|
91
|
+
constructor(response = 'Method Not Allowed') {
|
|
92
|
+
super(response, 405);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
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
|
+
class NotAcceptableException extends http_exception_1.HttpException {
|
|
103
|
+
constructor(response = 'Not Acceptable') {
|
|
104
|
+
super(response, 406);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.NotAcceptableException = NotAcceptableException;
|
|
108
|
+
/**
|
|
109
|
+
* 408 Request Timeout
|
|
110
|
+
*
|
|
111
|
+
* The server timed out waiting for the request.
|
|
112
|
+
*/
|
|
113
|
+
class RequestTimeoutException extends http_exception_1.HttpException {
|
|
114
|
+
constructor(response = 'Request Timeout') {
|
|
115
|
+
super(response, 408);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
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
|
+
class ConflictException extends http_exception_1.HttpException {
|
|
131
|
+
constructor(response = 'Conflict') {
|
|
132
|
+
super(response, 409);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.ConflictException = ConflictException;
|
|
136
|
+
/**
|
|
137
|
+
* 410 Gone
|
|
138
|
+
*
|
|
139
|
+
* The resource is no longer available and will not be available again.
|
|
140
|
+
*/
|
|
141
|
+
class GoneException extends http_exception_1.HttpException {
|
|
142
|
+
constructor(response = 'Gone') {
|
|
143
|
+
super(response, 410);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
exports.GoneException = GoneException;
|
|
147
|
+
/**
|
|
148
|
+
* 413 Payload Too Large
|
|
149
|
+
*
|
|
150
|
+
* The request entity is larger than limits defined by the server.
|
|
151
|
+
*/
|
|
152
|
+
class PayloadTooLargeException extends http_exception_1.HttpException {
|
|
153
|
+
constructor(response = 'Payload Too Large') {
|
|
154
|
+
super(response, 413);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
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
|
+
class UnsupportedMediaTypeException extends http_exception_1.HttpException {
|
|
164
|
+
constructor(response = 'Unsupported Media Type') {
|
|
165
|
+
super(response, 415);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
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
|
+
class UnprocessableEntityException extends http_exception_1.HttpException {
|
|
186
|
+
constructor(response = 'Unprocessable Entity') {
|
|
187
|
+
super(response, 422);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
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
|
+
class TooManyRequestsException extends http_exception_1.HttpException {
|
|
202
|
+
constructor(response = 'Too Many Requests') {
|
|
203
|
+
super(response, 429);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
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
|
+
class InternalServerErrorException extends http_exception_1.HttpException {
|
|
221
|
+
constructor(response = 'Internal Server Error') {
|
|
222
|
+
super(response, 500);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
exports.InternalServerErrorException = InternalServerErrorException;
|
|
226
|
+
/**
|
|
227
|
+
* 501 Not Implemented
|
|
228
|
+
*
|
|
229
|
+
* The server does not support the functionality required to fulfill the request.
|
|
230
|
+
*/
|
|
231
|
+
class NotImplementedException extends http_exception_1.HttpException {
|
|
232
|
+
constructor(response = 'Not Implemented') {
|
|
233
|
+
super(response, 501);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
exports.NotImplementedException = NotImplementedException;
|
|
237
|
+
/**
|
|
238
|
+
* 502 Bad Gateway
|
|
239
|
+
*
|
|
240
|
+
* The server received an invalid response from an upstream server.
|
|
241
|
+
*/
|
|
242
|
+
class BadGatewayException extends http_exception_1.HttpException {
|
|
243
|
+
constructor(response = 'Bad Gateway') {
|
|
244
|
+
super(response, 502);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
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
|
+
class ServiceUnavailableException extends http_exception_1.HttpException {
|
|
259
|
+
constructor(response = 'Service Unavailable') {
|
|
260
|
+
super(response, 503);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
exports.ServiceUnavailableException = ServiceUnavailableException;
|
|
264
|
+
/**
|
|
265
|
+
* 504 Gateway Timeout
|
|
266
|
+
*
|
|
267
|
+
* The server did not receive a timely response from an upstream server.
|
|
268
|
+
*/
|
|
269
|
+
class GatewayTimeoutException extends http_exception_1.HttpException {
|
|
270
|
+
constructor(response = 'Gateway Timeout') {
|
|
271
|
+
super(response, 504);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
exports.GatewayTimeoutException = GatewayTimeoutException;
|
|
275
|
+
//# sourceMappingURL=exceptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exceptions.js","sourceRoot":"","sources":["../../../src/core/exceptions/exceptions.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
export declare class HttpException extends Error {
|
|
21
|
+
/**
|
|
22
|
+
* HTTP status code
|
|
23
|
+
*/
|
|
24
|
+
readonly statusCode: number;
|
|
25
|
+
/**
|
|
26
|
+
* Error response object
|
|
27
|
+
*/
|
|
28
|
+
readonly response: HttpExceptionResponse;
|
|
29
|
+
/**
|
|
30
|
+
* Timestamp when the exception was created
|
|
31
|
+
*/
|
|
32
|
+
readonly timestamp: string;
|
|
33
|
+
constructor(response: string | HttpExceptionBody, statusCode?: number);
|
|
34
|
+
/**
|
|
35
|
+
* Get the response object for JSON serialization
|
|
36
|
+
*/
|
|
37
|
+
getResponse(): HttpExceptionResponse;
|
|
38
|
+
/**
|
|
39
|
+
* Get the HTTP status code
|
|
40
|
+
*/
|
|
41
|
+
getStatus(): number;
|
|
42
|
+
/**
|
|
43
|
+
* Get default error name for status code
|
|
44
|
+
*/
|
|
45
|
+
private getDefaultError;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Exception body structure for custom responses
|
|
49
|
+
*/
|
|
50
|
+
export interface HttpExceptionBody {
|
|
51
|
+
/** Error message */
|
|
52
|
+
message: string;
|
|
53
|
+
/** Error type/name (e.g., "Bad Request", "Validation Error") */
|
|
54
|
+
error?: string;
|
|
55
|
+
/** Additional error details */
|
|
56
|
+
details?: unknown;
|
|
57
|
+
/** Application-specific error code */
|
|
58
|
+
code?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Standard HTTP exception response format
|
|
62
|
+
*/
|
|
63
|
+
export interface HttpExceptionResponse {
|
|
64
|
+
/** HTTP status code */
|
|
65
|
+
statusCode: number;
|
|
66
|
+
/** Error message */
|
|
67
|
+
message: string;
|
|
68
|
+
/** Error type/name */
|
|
69
|
+
error: string;
|
|
70
|
+
/** ISO timestamp */
|
|
71
|
+
timestamp: string;
|
|
72
|
+
/** Additional error details (optional) */
|
|
73
|
+
details?: unknown;
|
|
74
|
+
/** Application-specific error code (optional) */
|
|
75
|
+
code?: string;
|
|
76
|
+
/** Request path (added by filter) */
|
|
77
|
+
path?: string;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=http-exception.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-exception.d.ts","sourceRoot":"","sources":["../../../src/core/exceptions/http-exception.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,CAAC;IAEzC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBAGzB,QAAQ,EAAE,MAAM,GAAG,iBAAiB,EACpC,UAAU,GAAE,MAAY;IAmC1B;;OAEG;IACH,WAAW,IAAI,qBAAqB;IAIpC;;OAEG;IACH,SAAS,IAAI,MAAM;IAInB;;OAEG;IACH,OAAO,CAAC,eAAe;CAuBxB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,oBAAoB;IACpB,OAAO,EAAE,MAAM,CAAC;IAEhB,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,+BAA+B;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,sCAAsC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,uBAAuB;IACvB,UAAU,EAAE,MAAM,CAAC;IAEnB,oBAAoB;IACpB,OAAO,EAAE,MAAM,CAAC;IAEhB,sBAAsB;IACtB,KAAK,EAAE,MAAM,CAAC;IAEd,oBAAoB;IACpB,SAAS,EAAE,MAAM,CAAC;IAElB,0CAA0C;IAC1C,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,iDAAiD;IACjD,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,qCAAqC;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpException = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* HTTP Exception Base Class
|
|
6
|
+
*
|
|
7
|
+
* Base class for all HTTP exceptions in Rikta.
|
|
8
|
+
* Provides a standard structure for error responses.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* // Throw directly
|
|
13
|
+
* throw new HttpException('Something went wrong', 500);
|
|
14
|
+
*
|
|
15
|
+
* // With additional details
|
|
16
|
+
* throw new HttpException({
|
|
17
|
+
* message: 'Validation failed',
|
|
18
|
+
* error: 'Bad Request',
|
|
19
|
+
* details: { field: 'email', reason: 'Invalid format' }
|
|
20
|
+
* }, 400);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
class HttpException extends Error {
|
|
24
|
+
/**
|
|
25
|
+
* HTTP status code
|
|
26
|
+
*/
|
|
27
|
+
statusCode;
|
|
28
|
+
/**
|
|
29
|
+
* Error response object
|
|
30
|
+
*/
|
|
31
|
+
response;
|
|
32
|
+
/**
|
|
33
|
+
* Timestamp when the exception was created
|
|
34
|
+
*/
|
|
35
|
+
timestamp;
|
|
36
|
+
constructor(response, statusCode = 500) {
|
|
37
|
+
const message = typeof response === 'string'
|
|
38
|
+
? response
|
|
39
|
+
: response.message;
|
|
40
|
+
super(message);
|
|
41
|
+
this.name = this.constructor.name;
|
|
42
|
+
this.statusCode = statusCode;
|
|
43
|
+
this.timestamp = new Date().toISOString();
|
|
44
|
+
// Build response object
|
|
45
|
+
if (typeof response === 'string') {
|
|
46
|
+
this.response = {
|
|
47
|
+
statusCode,
|
|
48
|
+
message,
|
|
49
|
+
error: this.getDefaultError(statusCode),
|
|
50
|
+
timestamp: this.timestamp,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
this.response = {
|
|
55
|
+
statusCode,
|
|
56
|
+
message: response.message,
|
|
57
|
+
error: response.error ?? this.getDefaultError(statusCode),
|
|
58
|
+
timestamp: this.timestamp,
|
|
59
|
+
...(response.details ? { details: response.details } : {}),
|
|
60
|
+
...(response.code ? { code: response.code } : {}),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// Capture stack trace
|
|
64
|
+
Error.captureStackTrace(this, this.constructor);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get the response object for JSON serialization
|
|
68
|
+
*/
|
|
69
|
+
getResponse() {
|
|
70
|
+
return this.response;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get the HTTP status code
|
|
74
|
+
*/
|
|
75
|
+
getStatus() {
|
|
76
|
+
return this.statusCode;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get default error name for status code
|
|
80
|
+
*/
|
|
81
|
+
getDefaultError(statusCode) {
|
|
82
|
+
const errors = {
|
|
83
|
+
400: 'Bad Request',
|
|
84
|
+
401: 'Unauthorized',
|
|
85
|
+
403: 'Forbidden',
|
|
86
|
+
404: 'Not Found',
|
|
87
|
+
405: 'Method Not Allowed',
|
|
88
|
+
406: 'Not Acceptable',
|
|
89
|
+
408: 'Request Timeout',
|
|
90
|
+
409: 'Conflict',
|
|
91
|
+
410: 'Gone',
|
|
92
|
+
413: 'Payload Too Large',
|
|
93
|
+
415: 'Unsupported Media Type',
|
|
94
|
+
422: 'Unprocessable Entity',
|
|
95
|
+
429: 'Too Many Requests',
|
|
96
|
+
500: 'Internal Server Error',
|
|
97
|
+
501: 'Not Implemented',
|
|
98
|
+
502: 'Bad Gateway',
|
|
99
|
+
503: 'Service Unavailable',
|
|
100
|
+
504: 'Gateway Timeout',
|
|
101
|
+
};
|
|
102
|
+
return errors[statusCode] ?? 'Error';
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.HttpException = HttpException;
|
|
106
|
+
//# sourceMappingURL=http-exception.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-exception.js","sourceRoot":"","sources":["../../../src/core/exceptions/http-exception.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAa,aAAc,SAAQ,KAAK;IACtC;;OAEG;IACM,UAAU,CAAS;IAE5B;;OAEG;IACM,QAAQ,CAAwB;IAEzC;;OAEG;IACM,SAAS,CAAS;IAE3B,YACE,QAAoC,EACpC,aAAqB,GAAG;QAExB,MAAM,OAAO,GAAG,OAAO,QAAQ,KAAK,QAAQ;YAC1C,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;QAErB,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAE1C,wBAAwB;QACxB,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACjC,IAAI,CAAC,QAAQ,GAAG;gBACd,UAAU;gBACV,OAAO;gBACP,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC;gBACvC,SAAS,EAAE,IAAI,CAAC,SAAS;aAC1B,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,QAAQ,GAAG;gBACd,UAAU;gBACV,OAAO,EAAE,QAAQ,CAAC,OAAO;gBACzB,KAAK,EAAE,QAAQ,CAAC,KAAK,IAAI,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC;gBACzD,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC1D,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAClD,CAAC;QACJ,CAAC;QAED,sBAAsB;QACtB,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;OAEG;IACK,eAAe,CAAC,UAAkB;QACxC,MAAM,MAAM,GAA2B;YACrC,GAAG,EAAE,aAAa;YAClB,GAAG,EAAE,cAAc;YACnB,GAAG,EAAE,WAAW;YAChB,GAAG,EAAE,WAAW;YAChB,GAAG,EAAE,oBAAoB;YACzB,GAAG,EAAE,gBAAgB;YACrB,GAAG,EAAE,iBAAiB;YACtB,GAAG,EAAE,UAAU;YACf,GAAG,EAAE,MAAM;YACX,GAAG,EAAE,mBAAmB;YACxB,GAAG,EAAE,wBAAwB;YAC7B,GAAG,EAAE,sBAAsB;YAC3B,GAAG,EAAE,mBAAmB;YACxB,GAAG,EAAE,uBAAuB;YAC5B,GAAG,EAAE,iBAAiB;YACtB,GAAG,EAAE,aAAa;YAClB,GAAG,EAAE,qBAAqB;YAC1B,GAAG,EAAE,iBAAiB;SACvB,CAAC;QACF,OAAO,MAAM,CAAC,UAAU,CAAC,IAAI,OAAO,CAAC;IACvC,CAAC;CACF;AA7FD,sCA6FC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { HttpException, HttpExceptionBody, HttpExceptionResponse } from './http-exception';
|
|
2
|
+
export { BadRequestException, UnauthorizedException, ForbiddenException, NotFoundException, MethodNotAllowedException, NotAcceptableException, RequestTimeoutException, ConflictException, GoneException, PayloadTooLargeException, UnsupportedMediaTypeException, UnprocessableEntityException, TooManyRequestsException, InternalServerErrorException, NotImplementedException, BadGatewayException, ServiceUnavailableException, GatewayTimeoutException, } from './exceptions';
|
|
3
|
+
export { ExceptionFilter, ExceptionContext, ErrorResponse, GlobalExceptionFilter, GlobalExceptionFilterOptions, createExceptionHandler, } from './exception-filter';
|
|
4
|
+
export { Catch, CatchMetadata, CATCH_METADATA, getCatchMetadata } from './catch.decorator';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/exceptions/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAG3F,OAAO,EAEL,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EACjB,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EACjB,aAAa,EACb,wBAAwB,EACxB,6BAA6B,EAC7B,4BAA4B,EAC5B,wBAAwB,EAExB,4BAA4B,EAC5B,uBAAuB,EACvB,mBAAmB,EACnB,2BAA2B,EAC3B,uBAAuB,GACxB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,qBAAqB,EACrB,4BAA4B,EAC5B,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCatchMetadata = exports.CATCH_METADATA = exports.Catch = exports.createExceptionHandler = exports.GlobalExceptionFilter = 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 = exports.HttpException = void 0;
|
|
4
|
+
// HTTP Exception
|
|
5
|
+
var http_exception_1 = require("./http-exception");
|
|
6
|
+
Object.defineProperty(exports, "HttpException", { enumerable: true, get: function () { return http_exception_1.HttpException; } });
|
|
7
|
+
// Specific Exceptions
|
|
8
|
+
var exceptions_1 = require("./exceptions");
|
|
9
|
+
// 4xx Client Errors
|
|
10
|
+
Object.defineProperty(exports, "BadRequestException", { enumerable: true, get: function () { return exceptions_1.BadRequestException; } });
|
|
11
|
+
Object.defineProperty(exports, "UnauthorizedException", { enumerable: true, get: function () { return exceptions_1.UnauthorizedException; } });
|
|
12
|
+
Object.defineProperty(exports, "ForbiddenException", { enumerable: true, get: function () { return exceptions_1.ForbiddenException; } });
|
|
13
|
+
Object.defineProperty(exports, "NotFoundException", { enumerable: true, get: function () { return exceptions_1.NotFoundException; } });
|
|
14
|
+
Object.defineProperty(exports, "MethodNotAllowedException", { enumerable: true, get: function () { return exceptions_1.MethodNotAllowedException; } });
|
|
15
|
+
Object.defineProperty(exports, "NotAcceptableException", { enumerable: true, get: function () { return exceptions_1.NotAcceptableException; } });
|
|
16
|
+
Object.defineProperty(exports, "RequestTimeoutException", { enumerable: true, get: function () { return exceptions_1.RequestTimeoutException; } });
|
|
17
|
+
Object.defineProperty(exports, "ConflictException", { enumerable: true, get: function () { return exceptions_1.ConflictException; } });
|
|
18
|
+
Object.defineProperty(exports, "GoneException", { enumerable: true, get: function () { return exceptions_1.GoneException; } });
|
|
19
|
+
Object.defineProperty(exports, "PayloadTooLargeException", { enumerable: true, get: function () { return exceptions_1.PayloadTooLargeException; } });
|
|
20
|
+
Object.defineProperty(exports, "UnsupportedMediaTypeException", { enumerable: true, get: function () { return exceptions_1.UnsupportedMediaTypeException; } });
|
|
21
|
+
Object.defineProperty(exports, "UnprocessableEntityException", { enumerable: true, get: function () { return exceptions_1.UnprocessableEntityException; } });
|
|
22
|
+
Object.defineProperty(exports, "TooManyRequestsException", { enumerable: true, get: function () { return exceptions_1.TooManyRequestsException; } });
|
|
23
|
+
// 5xx Server Errors
|
|
24
|
+
Object.defineProperty(exports, "InternalServerErrorException", { enumerable: true, get: function () { return exceptions_1.InternalServerErrorException; } });
|
|
25
|
+
Object.defineProperty(exports, "NotImplementedException", { enumerable: true, get: function () { return exceptions_1.NotImplementedException; } });
|
|
26
|
+
Object.defineProperty(exports, "BadGatewayException", { enumerable: true, get: function () { return exceptions_1.BadGatewayException; } });
|
|
27
|
+
Object.defineProperty(exports, "ServiceUnavailableException", { enumerable: true, get: function () { return exceptions_1.ServiceUnavailableException; } });
|
|
28
|
+
Object.defineProperty(exports, "GatewayTimeoutException", { enumerable: true, get: function () { return exceptions_1.GatewayTimeoutException; } });
|
|
29
|
+
// Exception Filter
|
|
30
|
+
var exception_filter_1 = require("./exception-filter");
|
|
31
|
+
Object.defineProperty(exports, "GlobalExceptionFilter", { enumerable: true, get: function () { return exception_filter_1.GlobalExceptionFilter; } });
|
|
32
|
+
Object.defineProperty(exports, "createExceptionHandler", { enumerable: true, get: function () { return exception_filter_1.createExceptionHandler; } });
|
|
33
|
+
// Catch Decorator
|
|
34
|
+
var catch_decorator_1 = require("./catch.decorator");
|
|
35
|
+
Object.defineProperty(exports, "Catch", { enumerable: true, get: function () { return catch_decorator_1.Catch; } });
|
|
36
|
+
Object.defineProperty(exports, "CATCH_METADATA", { enumerable: true, get: function () { return catch_decorator_1.CATCH_METADATA; } });
|
|
37
|
+
Object.defineProperty(exports, "getCatchMetadata", { enumerable: true, get: function () { return catch_decorator_1.getCatchMetadata; } });
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/exceptions/index.ts"],"names":[],"mappings":";;;AAAA,iBAAiB;AACjB,mDAA2F;AAAlF,+GAAA,aAAa,OAAA;AAEtB,sBAAsB;AACtB,2CAqBsB;AApBpB,oBAAoB;AACpB,iHAAA,mBAAmB,OAAA;AACnB,mHAAA,qBAAqB,OAAA;AACrB,gHAAA,kBAAkB,OAAA;AAClB,+GAAA,iBAAiB,OAAA;AACjB,uHAAA,yBAAyB,OAAA;AACzB,oHAAA,sBAAsB,OAAA;AACtB,qHAAA,uBAAuB,OAAA;AACvB,+GAAA,iBAAiB,OAAA;AACjB,2GAAA,aAAa,OAAA;AACb,sHAAA,wBAAwB,OAAA;AACxB,2HAAA,6BAA6B,OAAA;AAC7B,0HAAA,4BAA4B,OAAA;AAC5B,sHAAA,wBAAwB,OAAA;AACxB,oBAAoB;AACpB,0HAAA,4BAA4B,OAAA;AAC5B,qHAAA,uBAAuB,OAAA;AACvB,iHAAA,mBAAmB,OAAA;AACnB,yHAAA,2BAA2B,OAAA;AAC3B,qHAAA,uBAAuB,OAAA;AAGzB,mBAAmB;AACnB,uDAO4B;AAH1B,yHAAA,qBAAqB,OAAA;AAErB,0HAAA,sBAAsB,OAAA;AAGxB,kBAAkB;AAClB,qDAA2F;AAAlF,wGAAA,KAAK,OAAA;AAAiB,iHAAA,cAAc,OAAA;AAAE,mHAAA,gBAAgB,OAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './constants';
|
|
3
|
+
export * from './container';
|
|
4
|
+
export * from './registry';
|
|
5
|
+
export * from './discovery';
|
|
6
|
+
export * from './lifecycle';
|
|
7
|
+
export * from './router/router';
|
|
8
|
+
export * from './application';
|
|
9
|
+
export * from './decorators';
|
|
10
|
+
export * from './exceptions';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AACA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// Core exports
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
|
+
__exportStar(require("./constants"), exports);
|
|
20
|
+
__exportStar(require("./container"), exports);
|
|
21
|
+
__exportStar(require("./registry"), exports);
|
|
22
|
+
__exportStar(require("./discovery"), exports);
|
|
23
|
+
__exportStar(require("./lifecycle"), exports);
|
|
24
|
+
__exportStar(require("./router/router"), exports);
|
|
25
|
+
__exportStar(require("./application"), exports);
|
|
26
|
+
__exportStar(require("./decorators"), exports);
|
|
27
|
+
__exportStar(require("./exceptions"), exports);
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,eAAe;AACf,0CAAwB;AACxB,8CAA4B;AAC5B,8CAA4B;AAC5B,6CAA2B;AAC3B,8CAA4B;AAC5B,8CAA4B;AAC5B,kDAAgC;AAChC,gDAA8B;AAC9B,+CAA6B;AAC7B,+CAA6B"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Constructor } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Event payload types for built-in lifecycle events
|
|
4
|
+
*/
|
|
5
|
+
export interface EventPayload {
|
|
6
|
+
'app:discovery': {
|
|
7
|
+
files: string[];
|
|
8
|
+
};
|
|
9
|
+
'app:providers': {
|
|
10
|
+
count: number;
|
|
11
|
+
};
|
|
12
|
+
'provider:init': {
|
|
13
|
+
provider: Constructor;
|
|
14
|
+
name: string;
|
|
15
|
+
priority: number;
|
|
16
|
+
};
|
|
17
|
+
'app:routes': {
|
|
18
|
+
count: number;
|
|
19
|
+
};
|
|
20
|
+
'app:bootstrap': {
|
|
21
|
+
providerCount: number;
|
|
22
|
+
};
|
|
23
|
+
'app:listen': {
|
|
24
|
+
address: string;
|
|
25
|
+
port: number;
|
|
26
|
+
};
|
|
27
|
+
'app:shutdown': {
|
|
28
|
+
signal?: string;
|
|
29
|
+
};
|
|
30
|
+
'provider:destroy': {
|
|
31
|
+
provider: Constructor;
|
|
32
|
+
name: string;
|
|
33
|
+
};
|
|
34
|
+
'app:destroy': {
|
|
35
|
+
uptime: number;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export type LifecycleEvent = keyof EventPayload;
|
|
39
|
+
type Listener<E extends LifecycleEvent> = (payload: EventPayload[E]) => void | Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* EventBus - Central event system for lifecycle and custom events
|
|
42
|
+
*
|
|
43
|
+
* Provides a flexible pub/sub mechanism that works alongside
|
|
44
|
+
* the interface-based lifecycle hooks.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* @Injectable()
|
|
49
|
+
* class MonitoringService {
|
|
50
|
+
* constructor(private events: EventBus) {
|
|
51
|
+
* events.on('app:listen', ({ address }) => {
|
|
52
|
+
* console.log(`Server started at ${address}`);
|
|
53
|
+
* });
|
|
54
|
+
* }
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare class EventBus {
|
|
59
|
+
private listeners;
|
|
60
|
+
private onceListeners;
|
|
61
|
+
/**
|
|
62
|
+
* Subscribe to an event
|
|
63
|
+
* @returns Unsubscribe function
|
|
64
|
+
*/
|
|
65
|
+
on<E extends LifecycleEvent>(event: E, listener: Listener<E>): () => void;
|
|
66
|
+
on<T = unknown>(event: string, listener: (payload: T) => void | Promise<void>): () => void;
|
|
67
|
+
/**
|
|
68
|
+
* Subscribe to an event once
|
|
69
|
+
*/
|
|
70
|
+
once<E extends LifecycleEvent>(event: E, listener: Listener<E>): void;
|
|
71
|
+
once<T = unknown>(event: string, listener: (payload: T) => void | Promise<void>): void;
|
|
72
|
+
/**
|
|
73
|
+
* Emit an event to all subscribers
|
|
74
|
+
*/
|
|
75
|
+
emit<E extends LifecycleEvent>(event: E, payload: EventPayload[E]): Promise<void>;
|
|
76
|
+
emit<T = unknown>(event: string, payload: T): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Wait for an event (Promise-based)
|
|
79
|
+
*/
|
|
80
|
+
waitFor<E extends LifecycleEvent>(event: E): Promise<EventPayload[E]>;
|
|
81
|
+
waitFor<T = unknown>(event: string): Promise<T>;
|
|
82
|
+
/**
|
|
83
|
+
* Remove all listeners for an event
|
|
84
|
+
*/
|
|
85
|
+
off(event: string): void;
|
|
86
|
+
/**
|
|
87
|
+
* Remove all listeners
|
|
88
|
+
*/
|
|
89
|
+
clear(): void;
|
|
90
|
+
/**
|
|
91
|
+
* Get listener count for an event
|
|
92
|
+
*/
|
|
93
|
+
listenerCount(event: string): number;
|
|
94
|
+
}
|
|
95
|
+
export {};
|
|
96
|
+
//# sourceMappingURL=event-bus.d.ts.map
|