wynkjs 1.0.8 → 1.0.9

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 (85) hide show
  1. package/dist/common/http-status.enum.d.ts +129 -0
  2. package/dist/common/http-status.enum.js +135 -0
  3. package/dist/cors.d.ts +0 -1
  4. package/dist/cors.js +2 -2
  5. package/dist/database.d.ts +0 -1
  6. package/dist/decorators/database.decorators.d.ts +0 -1
  7. package/dist/decorators/database.decorators.js +2 -2
  8. package/dist/decorators/di.decorators.d.ts +13 -0
  9. package/dist/decorators/di.decorators.js +28 -0
  10. package/dist/decorators/exception.decorators.d.ts +34 -1
  11. package/dist/decorators/exception.decorators.js +44 -6
  12. package/dist/decorators/formatter.decorators.d.ts +0 -1
  13. package/dist/decorators/guard.decorators.d.ts +22 -3
  14. package/dist/decorators/guard.decorators.js +1 -0
  15. package/dist/decorators/http.decorators.d.ts +30 -1
  16. package/dist/decorators/http.decorators.js +25 -4
  17. package/dist/decorators/interceptor.advanced.d.ts +0 -1
  18. package/dist/decorators/interceptor.decorators.d.ts +40 -3
  19. package/dist/decorators/metadata.decorators.d.ts +71 -0
  20. package/dist/decorators/metadata.decorators.js +134 -0
  21. package/dist/decorators/param.decorators.d.ts +27 -2
  22. package/dist/decorators/pipe.advanced.d.ts +19 -26
  23. package/dist/decorators/pipe.advanced.js +84 -54
  24. package/dist/decorators/pipe.decorators.d.ts +76 -12
  25. package/dist/decorators/pipe.decorators.js +55 -8
  26. package/dist/dto.d.ts +0 -1
  27. package/dist/factory.d.ts +270 -20
  28. package/dist/factory.js +284 -68
  29. package/dist/filters/exception.filters.d.ts +0 -1
  30. package/dist/filters/exception.filters.js +3 -3
  31. package/dist/global-prefix.d.ts +2 -3
  32. package/dist/global-prefix.js +4 -6
  33. package/dist/index.d.ts +6 -1
  34. package/dist/index.js +10 -0
  35. package/dist/interfaces/interceptor.interface.d.ts +0 -1
  36. package/dist/interfaces/lifecycle.interface.d.ts +53 -0
  37. package/dist/interfaces/lifecycle.interface.js +1 -0
  38. package/dist/module.d.ts +53 -0
  39. package/dist/module.js +35 -0
  40. package/dist/pipes/validation.pipe.d.ts +1 -2
  41. package/dist/pipes/validation.pipe.js +1 -1
  42. package/dist/plugins/compression.d.ts +0 -1
  43. package/dist/plugins/compression.js +24 -9
  44. package/dist/request.d.ts +0 -1
  45. package/dist/request.js +1 -0
  46. package/dist/response.d.ts +0 -1
  47. package/dist/response.js +1 -0
  48. package/dist/schema-registry.d.ts +0 -1
  49. package/dist/testing/index.d.ts +0 -1
  50. package/dist/testing/test-utils.d.ts +0 -1
  51. package/dist/ultra-optimized-handler.d.ts +0 -1
  52. package/dist/ultra-optimized-handler.js +16 -3
  53. package/package.json +13 -4
  54. package/dist/cors.d.ts.map +0 -1
  55. package/dist/database.d.ts.map +0 -1
  56. package/dist/decorators/database.decorators.d.ts.map +0 -1
  57. package/dist/decorators/exception.advanced.d.ts +0 -457
  58. package/dist/decorators/exception.advanced.d.ts.map +0 -1
  59. package/dist/decorators/exception.advanced.js +0 -742
  60. package/dist/decorators/exception.decorators.d.ts.map +0 -1
  61. package/dist/decorators/formatter.decorators.d.ts.map +0 -1
  62. package/dist/decorators/guard.decorators.d.ts.map +0 -1
  63. package/dist/decorators/http.decorators.d.ts.map +0 -1
  64. package/dist/decorators/interceptor.advanced.d.ts.map +0 -1
  65. package/dist/decorators/interceptor.decorators.d.ts.map +0 -1
  66. package/dist/decorators/param.decorators.d.ts.map +0 -1
  67. package/dist/decorators/pipe.advanced.d.ts.map +0 -1
  68. package/dist/decorators/pipe.decorators.d.ts.map +0 -1
  69. package/dist/dto.d.ts.map +0 -1
  70. package/dist/factory.d.ts.map +0 -1
  71. package/dist/filters/exception.filters.d.ts.map +0 -1
  72. package/dist/global-prefix.d.ts.map +0 -1
  73. package/dist/index.d.ts.map +0 -1
  74. package/dist/interfaces/interceptor.interface.d.ts.map +0 -1
  75. package/dist/optimized-handler.d.ts +0 -31
  76. package/dist/optimized-handler.d.ts.map +0 -1
  77. package/dist/optimized-handler.js +0 -180
  78. package/dist/pipes/validation.pipe.d.ts.map +0 -1
  79. package/dist/plugins/compression.d.ts.map +0 -1
  80. package/dist/request.d.ts.map +0 -1
  81. package/dist/response.d.ts.map +0 -1
  82. package/dist/schema-registry.d.ts.map +0 -1
  83. package/dist/testing/index.d.ts.map +0 -1
  84. package/dist/testing/test-utils.d.ts.map +0 -1
  85. package/dist/ultra-optimized-handler.d.ts.map +0 -1
@@ -0,0 +1,129 @@
1
+ /**
2
+ * HTTP Status Codes enum for WynkJS Framework.
3
+ *
4
+ * Provides named constants for all standard HTTP status codes (RFC 7231 and beyond),
5
+ * matching NestJS's HttpStatus enum for API compatibility.
6
+ *
7
+ * @example
8
+ * import { HttpStatus } from 'wynkjs';
9
+ *
10
+ * @Get('/')
11
+ * @HttpCode(HttpStatus.OK)
12
+ * findAll() { return []; }
13
+ *
14
+ * throw new HttpException('Not found', HttpStatus.NOT_FOUND);
15
+ *
16
+ * @since 1.0.0
17
+ */
18
+ export declare enum HttpStatus {
19
+ /** 100 Continue */
20
+ CONTINUE = 100,
21
+ /** 101 Switching Protocols */
22
+ SWITCHING_PROTOCOLS = 101,
23
+ /** 102 Processing */
24
+ PROCESSING = 102,
25
+ /** 103 Early Hints */
26
+ EARLYHINTS = 103,
27
+ /** 200 OK */
28
+ OK = 200,
29
+ /** 201 Created */
30
+ CREATED = 201,
31
+ /** 202 Accepted */
32
+ ACCEPTED = 202,
33
+ /** 203 Non-Authoritative Information */
34
+ NON_AUTHORITATIVE_INFORMATION = 203,
35
+ /** 204 No Content */
36
+ NO_CONTENT = 204,
37
+ /** 205 Reset Content */
38
+ RESET_CONTENT = 205,
39
+ /** 206 Partial Content */
40
+ PARTIAL_CONTENT = 206,
41
+ /** 207 Multi-Status */
42
+ MULTI_STATUS = 207,
43
+ /** 208 Already Reported */
44
+ ALREADY_REPORTED = 208,
45
+ /** 210 Content Different */
46
+ CONTENT_DIFFERENT = 210,
47
+ /** 300 Multiple Choices */
48
+ AMBIGUOUS = 300,
49
+ /** 301 Moved Permanently */
50
+ MOVED_PERMANENTLY = 301,
51
+ /** 302 Found */
52
+ FOUND = 302,
53
+ /** 303 See Other */
54
+ SEE_OTHER = 303,
55
+ /** 304 Not Modified */
56
+ NOT_MODIFIED = 304,
57
+ /** 307 Temporary Redirect */
58
+ TEMPORARY_REDIRECT = 307,
59
+ /** 308 Permanent Redirect */
60
+ PERMANENT_REDIRECT = 308,
61
+ /** 400 Bad Request */
62
+ BAD_REQUEST = 400,
63
+ /** 401 Unauthorized */
64
+ UNAUTHORIZED = 401,
65
+ /** 402 Payment Required */
66
+ PAYMENT_REQUIRED = 402,
67
+ /** 403 Forbidden */
68
+ FORBIDDEN = 403,
69
+ /** 404 Not Found */
70
+ NOT_FOUND = 404,
71
+ /** 405 Method Not Allowed */
72
+ METHOD_NOT_ALLOWED = 405,
73
+ /** 406 Not Acceptable */
74
+ NOT_ACCEPTABLE = 406,
75
+ /** 407 Proxy Authentication Required */
76
+ PROXY_AUTHENTICATION_REQUIRED = 407,
77
+ /** 408 Request Timeout */
78
+ REQUEST_TIMEOUT = 408,
79
+ /** 409 Conflict */
80
+ CONFLICT = 409,
81
+ /** 410 Gone */
82
+ GONE = 410,
83
+ /** 411 Length Required */
84
+ LENGTH_REQUIRED = 411,
85
+ /** 412 Precondition Failed */
86
+ PRECONDITION_FAILED = 412,
87
+ /** 413 Payload Too Large */
88
+ PAYLOAD_TOO_LARGE = 413,
89
+ /** 414 URI Too Long */
90
+ URI_TOO_LONG = 414,
91
+ /** 415 Unsupported Media Type */
92
+ UNSUPPORTED_MEDIA_TYPE = 415,
93
+ /** 416 Range Not Satisfiable */
94
+ REQUESTED_RANGE_NOT_SATISFIABLE = 416,
95
+ /** 417 Expectation Failed */
96
+ EXPECTATION_FAILED = 417,
97
+ /** 418 I'm a Teapot */
98
+ I_AM_A_TEAPOT = 418,
99
+ /** 421 Misdirected Request */
100
+ MISDIRECTED = 421,
101
+ /** 422 Unprocessable Entity */
102
+ UNPROCESSABLE_ENTITY = 422,
103
+ /** 423 Locked */
104
+ LOCKED = 423,
105
+ /** 424 Failed Dependency */
106
+ FAILED_DEPENDENCY = 424,
107
+ /** 428 Precondition Required */
108
+ PRECONDITION_REQUIRED = 428,
109
+ /** 429 Too Many Requests */
110
+ TOO_MANY_REQUESTS = 429,
111
+ /** 456 Unrecoverable Error */
112
+ UNRECOVERABLE_ERROR = 456,
113
+ /** 500 Internal Server Error */
114
+ INTERNAL_SERVER_ERROR = 500,
115
+ /** 501 Not Implemented */
116
+ NOT_IMPLEMENTED = 501,
117
+ /** 502 Bad Gateway */
118
+ BAD_GATEWAY = 502,
119
+ /** 503 Service Unavailable */
120
+ SERVICE_UNAVAILABLE = 503,
121
+ /** 504 Gateway Timeout */
122
+ GATEWAY_TIMEOUT = 504,
123
+ /** 505 HTTP Version Not Supported */
124
+ HTTP_VERSION_NOT_SUPPORTED = 505,
125
+ /** 507 Insufficient Storage */
126
+ INSUFFICIENT_STORAGE = 507,
127
+ /** 508 Loop Detected */
128
+ LOOP_DETECTED = 508
129
+ }
@@ -0,0 +1,135 @@
1
+ /**
2
+ * HTTP Status Codes enum for WynkJS Framework.
3
+ *
4
+ * Provides named constants for all standard HTTP status codes (RFC 7231 and beyond),
5
+ * matching NestJS's HttpStatus enum for API compatibility.
6
+ *
7
+ * @example
8
+ * import { HttpStatus } from 'wynkjs';
9
+ *
10
+ * @Get('/')
11
+ * @HttpCode(HttpStatus.OK)
12
+ * findAll() { return []; }
13
+ *
14
+ * throw new HttpException('Not found', HttpStatus.NOT_FOUND);
15
+ *
16
+ * @since 1.0.0
17
+ */
18
+ export var HttpStatus;
19
+ (function (HttpStatus) {
20
+ // 1xx Informational
21
+ /** 100 Continue */
22
+ HttpStatus[HttpStatus["CONTINUE"] = 100] = "CONTINUE";
23
+ /** 101 Switching Protocols */
24
+ HttpStatus[HttpStatus["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
25
+ /** 102 Processing */
26
+ HttpStatus[HttpStatus["PROCESSING"] = 102] = "PROCESSING";
27
+ /** 103 Early Hints */
28
+ HttpStatus[HttpStatus["EARLYHINTS"] = 103] = "EARLYHINTS";
29
+ // 2xx Success
30
+ /** 200 OK */
31
+ HttpStatus[HttpStatus["OK"] = 200] = "OK";
32
+ /** 201 Created */
33
+ HttpStatus[HttpStatus["CREATED"] = 201] = "CREATED";
34
+ /** 202 Accepted */
35
+ HttpStatus[HttpStatus["ACCEPTED"] = 202] = "ACCEPTED";
36
+ /** 203 Non-Authoritative Information */
37
+ HttpStatus[HttpStatus["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
38
+ /** 204 No Content */
39
+ HttpStatus[HttpStatus["NO_CONTENT"] = 204] = "NO_CONTENT";
40
+ /** 205 Reset Content */
41
+ HttpStatus[HttpStatus["RESET_CONTENT"] = 205] = "RESET_CONTENT";
42
+ /** 206 Partial Content */
43
+ HttpStatus[HttpStatus["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
44
+ /** 207 Multi-Status */
45
+ HttpStatus[HttpStatus["MULTI_STATUS"] = 207] = "MULTI_STATUS";
46
+ /** 208 Already Reported */
47
+ HttpStatus[HttpStatus["ALREADY_REPORTED"] = 208] = "ALREADY_REPORTED";
48
+ /** 210 Content Different */
49
+ HttpStatus[HttpStatus["CONTENT_DIFFERENT"] = 210] = "CONTENT_DIFFERENT";
50
+ // 3xx Redirection
51
+ /** 300 Multiple Choices */
52
+ HttpStatus[HttpStatus["AMBIGUOUS"] = 300] = "AMBIGUOUS";
53
+ /** 301 Moved Permanently */
54
+ HttpStatus[HttpStatus["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
55
+ /** 302 Found */
56
+ HttpStatus[HttpStatus["FOUND"] = 302] = "FOUND";
57
+ /** 303 See Other */
58
+ HttpStatus[HttpStatus["SEE_OTHER"] = 303] = "SEE_OTHER";
59
+ /** 304 Not Modified */
60
+ HttpStatus[HttpStatus["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
61
+ /** 307 Temporary Redirect */
62
+ HttpStatus[HttpStatus["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
63
+ /** 308 Permanent Redirect */
64
+ HttpStatus[HttpStatus["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
65
+ // 4xx Client Errors
66
+ /** 400 Bad Request */
67
+ HttpStatus[HttpStatus["BAD_REQUEST"] = 400] = "BAD_REQUEST";
68
+ /** 401 Unauthorized */
69
+ HttpStatus[HttpStatus["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
70
+ /** 402 Payment Required */
71
+ HttpStatus[HttpStatus["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
72
+ /** 403 Forbidden */
73
+ HttpStatus[HttpStatus["FORBIDDEN"] = 403] = "FORBIDDEN";
74
+ /** 404 Not Found */
75
+ HttpStatus[HttpStatus["NOT_FOUND"] = 404] = "NOT_FOUND";
76
+ /** 405 Method Not Allowed */
77
+ HttpStatus[HttpStatus["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
78
+ /** 406 Not Acceptable */
79
+ HttpStatus[HttpStatus["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
80
+ /** 407 Proxy Authentication Required */
81
+ HttpStatus[HttpStatus["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
82
+ /** 408 Request Timeout */
83
+ HttpStatus[HttpStatus["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
84
+ /** 409 Conflict */
85
+ HttpStatus[HttpStatus["CONFLICT"] = 409] = "CONFLICT";
86
+ /** 410 Gone */
87
+ HttpStatus[HttpStatus["GONE"] = 410] = "GONE";
88
+ /** 411 Length Required */
89
+ HttpStatus[HttpStatus["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
90
+ /** 412 Precondition Failed */
91
+ HttpStatus[HttpStatus["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
92
+ /** 413 Payload Too Large */
93
+ HttpStatus[HttpStatus["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
94
+ /** 414 URI Too Long */
95
+ HttpStatus[HttpStatus["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
96
+ /** 415 Unsupported Media Type */
97
+ HttpStatus[HttpStatus["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
98
+ /** 416 Range Not Satisfiable */
99
+ HttpStatus[HttpStatus["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
100
+ /** 417 Expectation Failed */
101
+ HttpStatus[HttpStatus["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
102
+ /** 418 I'm a Teapot */
103
+ HttpStatus[HttpStatus["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
104
+ /** 421 Misdirected Request */
105
+ HttpStatus[HttpStatus["MISDIRECTED"] = 421] = "MISDIRECTED";
106
+ /** 422 Unprocessable Entity */
107
+ HttpStatus[HttpStatus["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
108
+ /** 423 Locked */
109
+ HttpStatus[HttpStatus["LOCKED"] = 423] = "LOCKED";
110
+ /** 424 Failed Dependency */
111
+ HttpStatus[HttpStatus["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
112
+ /** 428 Precondition Required */
113
+ HttpStatus[HttpStatus["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
114
+ /** 429 Too Many Requests */
115
+ HttpStatus[HttpStatus["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
116
+ /** 456 Unrecoverable Error */
117
+ HttpStatus[HttpStatus["UNRECOVERABLE_ERROR"] = 456] = "UNRECOVERABLE_ERROR";
118
+ // 5xx Server Errors
119
+ /** 500 Internal Server Error */
120
+ HttpStatus[HttpStatus["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
121
+ /** 501 Not Implemented */
122
+ HttpStatus[HttpStatus["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
123
+ /** 502 Bad Gateway */
124
+ HttpStatus[HttpStatus["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
125
+ /** 503 Service Unavailable */
126
+ HttpStatus[HttpStatus["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
127
+ /** 504 Gateway Timeout */
128
+ HttpStatus[HttpStatus["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
129
+ /** 505 HTTP Version Not Supported */
130
+ HttpStatus[HttpStatus["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
131
+ /** 507 Insufficient Storage */
132
+ HttpStatus[HttpStatus["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
133
+ /** 508 Loop Detected */
134
+ HttpStatus[HttpStatus["LOOP_DETECTED"] = 508] = "LOOP_DETECTED";
135
+ })(HttpStatus || (HttpStatus = {}));
package/dist/cors.d.ts CHANGED
@@ -25,4 +25,3 @@ export declare function setupCors(app: Elysia, corsOptions: boolean | CorsOption
25
25
  * @returns true if valid, throws error if invalid
26
26
  */
27
27
  export declare function validateCorsOptions(corsOptions: boolean | CorsOptions): boolean;
28
- //# sourceMappingURL=cors.d.ts.map
package/dist/cors.js CHANGED
@@ -6,7 +6,7 @@
6
6
  */
7
7
  export function setupCors(app, corsOptions) {
8
8
  try {
9
- // Try to import @elysiajs/cors
9
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
10
10
  const { cors } = require("@elysiajs/cors");
11
11
  if (corsOptions === true) {
12
12
  // Simple CORS - allow all origins
@@ -63,7 +63,7 @@ export function setupCors(app, corsOptions) {
63
63
  console.log("✅ CORS enabled with custom configuration");
64
64
  }
65
65
  }
66
- catch (error) {
66
+ catch (_error) {
67
67
  console.error("❌ Failed to enable CORS: @elysiajs/cors package not found");
68
68
  console.error(" Install it with: bun add @elysiajs/cors");
69
69
  console.error(" Or remove cors option from ApplicationOptions to skip CORS setup");
@@ -33,4 +33,3 @@ export declare const MONGOOSE_EXAMPLE = "\n// With Mongoose (COPY TO YOUR PROJEC
33
33
  * That's it! WynkJS doesn't force you to use any specific pattern.
34
34
  * We give you the freedom to choose what works best for your project.
35
35
  */
36
- //# sourceMappingURL=database.d.ts.map
@@ -52,4 +52,3 @@ export declare function registerTables(tables: Record<string, any>): void;
52
52
  */
53
53
  export declare function registerModels(models: Record<string, any>): void;
54
54
  export { injectable, inject, singleton, container } from "tsyringe";
55
- //# sourceMappingURL=database.decorators.d.ts.map
@@ -99,7 +99,7 @@ export function InjectModel(model) {
99
99
  * ```
100
100
  */
101
101
  export function registerTables(tables) {
102
- for (const [name, table] of Object.entries(tables)) {
102
+ for (const [_name, table] of Object.entries(tables)) {
103
103
  const token = getOrCreateTableToken(table);
104
104
  if (!container.isRegistered(token)) {
105
105
  container.register(token, { useValue: table });
@@ -120,7 +120,7 @@ export function registerTables(tables) {
120
120
  * ```
121
121
  */
122
122
  export function registerModels(models) {
123
- for (const [name, model] of Object.entries(models)) {
123
+ for (const [_name, model] of Object.entries(models)) {
124
124
  const token = getOrCreateModelToken(model);
125
125
  if (!container.isRegistered(token)) {
126
126
  container.register(token, { useValue: model });
@@ -0,0 +1,13 @@
1
+ import "reflect-metadata";
2
+ /**
3
+ * Marks a constructor parameter or class property as optional.
4
+ * When the dependency cannot be resolved, `undefined` is injected instead of
5
+ * throwing an error.
6
+ *
7
+ * @example
8
+ * @Injectable()
9
+ * class MyService {
10
+ * constructor(@Optional() private logger?: LoggerService) {}
11
+ * }
12
+ */
13
+ export declare function Optional(): PropertyDecorator & ParameterDecorator;
@@ -0,0 +1,28 @@
1
+ import "reflect-metadata";
2
+ /**
3
+ * Marks a constructor parameter or class property as optional.
4
+ * When the dependency cannot be resolved, `undefined` is injected instead of
5
+ * throwing an error.
6
+ *
7
+ * @example
8
+ * @Injectable()
9
+ * class MyService {
10
+ * constructor(@Optional() private logger?: LoggerService) {}
11
+ * }
12
+ */
13
+ export function Optional() {
14
+ return (target, propertyKey, parameterIndex) => {
15
+ if (typeof parameterIndex === "number") {
16
+ const existingOptionals = [
17
+ ...(Reflect.getOwnMetadata("optional:params", target, propertyKey) ?? []),
18
+ ];
19
+ if (!existingOptionals.includes(parameterIndex)) {
20
+ existingOptionals.push(parameterIndex);
21
+ }
22
+ Reflect.defineMetadata("optional:params", existingOptionals, target, propertyKey);
23
+ }
24
+ else if (propertyKey !== undefined) {
25
+ Reflect.defineMetadata("optional", true, target, propertyKey);
26
+ }
27
+ };
28
+ }
@@ -37,6 +37,21 @@ export declare function UseFilters(...filters: (Function | WynkExceptionFilter)[
37
37
  /**
38
38
  * Built-in HTTP Exceptions
39
39
  */
40
+ /**
41
+ * Base HTTP exception class. All WynkJS HTTP exceptions extend this.
42
+ *
43
+ * Throw any `HttpException` subclass from a controller method — WynkJS will
44
+ * convert it into the appropriate HTTP response automatically.
45
+ *
46
+ * @param message - Human-readable error description sent in the response body.
47
+ * @param statusCode - HTTP status code (e.g. `404`, `500`).
48
+ * @param error - Short error category string (e.g. `'Not Found'`). Optional.
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * throw new HttpException('Custom error', 418);
53
+ * ```
54
+ */
40
55
  export declare class HttpException extends Error {
41
56
  readonly message: string;
42
57
  readonly statusCode: number;
@@ -46,42 +61,55 @@ export declare class HttpException extends Error {
46
61
  getStatus(): number;
47
62
  getResponse(): any;
48
63
  }
64
+ /** Thrown when the request is malformed or contains invalid data (HTTP 400). */
49
65
  export declare class BadRequestException extends HttpException {
50
66
  constructor(message?: string);
51
67
  }
68
+ /** Thrown when the request lacks valid authentication credentials (HTTP 401). */
52
69
  export declare class UnauthorizedException extends HttpException {
53
70
  constructor(message?: string);
54
71
  }
72
+ /** Thrown when the authenticated user does not have permission (HTTP 403). */
55
73
  export declare class ForbiddenException extends HttpException {
56
74
  constructor(message?: string);
57
75
  }
76
+ /** Thrown when the requested resource does not exist (HTTP 404). */
58
77
  export declare class NotFoundException extends HttpException {
59
78
  constructor(message?: string);
60
79
  }
80
+ /** Thrown when the HTTP method is not supported for the endpoint (HTTP 405). */
61
81
  export declare class MethodNotAllowedException extends HttpException {
62
82
  constructor(message?: string);
63
83
  }
84
+ /** Thrown when the server cannot produce a response matching the `Accept` header (HTTP 406). */
64
85
  export declare class NotAcceptableException extends HttpException {
65
86
  constructor(message?: string);
66
87
  }
88
+ /** Thrown when the server did not receive a timely response (HTTP 408). */
67
89
  export declare class RequestTimeoutException extends HttpException {
68
90
  constructor(message?: string);
69
91
  }
92
+ /** Thrown when the request conflicts with the current state of the resource (HTTP 409). */
70
93
  export declare class ConflictException extends HttpException {
71
94
  constructor(message?: string);
72
95
  }
96
+ /** Thrown when a resource already exists and cannot be created again (HTTP 409). */
73
97
  export declare class AlreadyExistsException extends HttpException {
74
98
  constructor(message?: string);
75
99
  }
100
+ /** Thrown when the requested resource is no longer available (HTTP 410). */
76
101
  export declare class GoneException extends HttpException {
77
102
  constructor(message?: string);
78
103
  }
104
+ /** Thrown when the request body exceeds the server's size limit (HTTP 413). */
79
105
  export declare class PayloadTooLargeException extends HttpException {
80
106
  constructor(message?: string);
81
107
  }
108
+ /** Thrown when the request's `Content-Type` is not supported (HTTP 415). */
82
109
  export declare class UnsupportedMediaTypeException extends HttpException {
83
110
  constructor(message?: string);
84
111
  }
112
+ /** Thrown when the request is well-formed but cannot be processed (HTTP 422). */
85
113
  export declare class UnprocessableEntityException extends HttpException {
86
114
  constructor(message?: string);
87
115
  }
@@ -100,6 +128,12 @@ export declare class ServiceUnavailableException extends HttpException {
100
128
  export declare class GatewayTimeoutException extends HttpException {
101
129
  constructor(message?: string);
102
130
  }
131
+ export declare class TooManyRequestsException extends HttpException {
132
+ constructor(message?: string);
133
+ }
134
+ export declare class HttpVersionNotSupportedException extends HttpException {
135
+ constructor(message?: string);
136
+ }
103
137
  /**
104
138
  * Helper function to execute exception filters
105
139
  */
@@ -209,4 +243,3 @@ export declare class BusinessLogicException implements WynkExceptionFilter {
209
243
  details: any;
210
244
  };
211
245
  }
212
- //# sourceMappingURL=exception.decorators.d.ts.map
@@ -52,6 +52,21 @@ export function UseFilters(...filters) {
52
52
  /**
53
53
  * Built-in HTTP Exceptions
54
54
  */
55
+ /**
56
+ * Base HTTP exception class. All WynkJS HTTP exceptions extend this.
57
+ *
58
+ * Throw any `HttpException` subclass from a controller method — WynkJS will
59
+ * convert it into the appropriate HTTP response automatically.
60
+ *
61
+ * @param message - Human-readable error description sent in the response body.
62
+ * @param statusCode - HTTP status code (e.g. `404`, `500`).
63
+ * @param error - Short error category string (e.g. `'Not Found'`). Optional.
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * throw new HttpException('Custom error', 418);
68
+ * ```
69
+ */
55
70
  export class HttpException extends Error {
56
71
  message;
57
72
  statusCode;
@@ -77,66 +92,79 @@ export class HttpException extends Error {
77
92
  };
78
93
  }
79
94
  }
95
+ /** Thrown when the request is malformed or contains invalid data (HTTP 400). */
80
96
  export class BadRequestException extends HttpException {
81
97
  constructor(message = "Bad Request") {
82
98
  super(message, 400, "Bad Request");
83
99
  }
84
100
  }
101
+ /** Thrown when the request lacks valid authentication credentials (HTTP 401). */
85
102
  export class UnauthorizedException extends HttpException {
86
103
  constructor(message = "Unauthorized") {
87
104
  super(message, 401, "Unauthorized");
88
105
  }
89
106
  }
107
+ /** Thrown when the authenticated user does not have permission (HTTP 403). */
90
108
  export class ForbiddenException extends HttpException {
91
109
  constructor(message = "Forbidden") {
92
110
  super(message, 403, "Forbidden");
93
111
  }
94
112
  }
113
+ /** Thrown when the requested resource does not exist (HTTP 404). */
95
114
  export class NotFoundException extends HttpException {
96
115
  constructor(message = "Not Found") {
97
116
  super(message, 404, "Not Found");
98
117
  }
99
118
  }
119
+ /** Thrown when the HTTP method is not supported for the endpoint (HTTP 405). */
100
120
  export class MethodNotAllowedException extends HttpException {
101
121
  constructor(message = "Method Not Allowed") {
102
122
  super(message, 405, "Method Not Allowed");
103
123
  }
104
124
  }
125
+ /** Thrown when the server cannot produce a response matching the `Accept` header (HTTP 406). */
105
126
  export class NotAcceptableException extends HttpException {
106
127
  constructor(message = "Not Acceptable") {
107
128
  super(message, 406, "Not Acceptable");
108
129
  }
109
130
  }
131
+ /** Thrown when the server did not receive a timely response (HTTP 408). */
110
132
  export class RequestTimeoutException extends HttpException {
111
133
  constructor(message = "Request Timeout") {
112
134
  super(message, 408, "Request Timeout");
113
135
  }
114
136
  }
137
+ /** Thrown when the request conflicts with the current state of the resource (HTTP 409). */
115
138
  export class ConflictException extends HttpException {
116
139
  constructor(message = "Conflict") {
117
140
  super(message, 409, "Conflict");
118
141
  }
119
142
  }
143
+ /** Thrown when a resource already exists and cannot be created again (HTTP 409). */
120
144
  export class AlreadyExistsException extends HttpException {
121
145
  constructor(message = "Resource Already Exists") {
122
146
  super(message, 409, "Conflict");
123
147
  }
124
148
  }
149
+ /** Thrown when the requested resource is no longer available (HTTP 410). */
125
150
  export class GoneException extends HttpException {
126
151
  constructor(message = "Gone") {
127
152
  super(message, 410, "Gone");
128
153
  }
129
154
  }
155
+ /** Thrown when the request body exceeds the server's size limit (HTTP 413). */
130
156
  export class PayloadTooLargeException extends HttpException {
131
157
  constructor(message = "Payload Too Large") {
132
158
  super(message, 413, "Payload Too Large");
133
159
  }
134
160
  }
161
+ /** Thrown when the request's `Content-Type` is not supported (HTTP 415). */
135
162
  export class UnsupportedMediaTypeException extends HttpException {
136
163
  constructor(message = "Unsupported Media Type") {
137
164
  super(message, 415, "Unsupported Media Type");
138
165
  }
139
166
  }
167
+ /** Thrown when the request is well-formed but cannot be processed (HTTP 422). */
140
168
  export class UnprocessableEntityException extends HttpException {
141
169
  constructor(message = "Unprocessable Entity") {
142
170
  super(message, 422, "Unprocessable Entity");
@@ -167,6 +195,16 @@ export class GatewayTimeoutException extends HttpException {
167
195
  super(message, 504, "Gateway Timeout");
168
196
  }
169
197
  }
198
+ export class TooManyRequestsException extends HttpException {
199
+ constructor(message = "Too Many Requests") {
200
+ super(message, 429, "Too Many Requests");
201
+ }
202
+ }
203
+ export class HttpVersionNotSupportedException extends HttpException {
204
+ constructor(message = "HTTP Version Not Supported") {
205
+ super(message, 505, "HTTP Version Not Supported");
206
+ }
207
+ }
170
208
  /**
171
209
  * Helper function to execute exception filters
172
210
  */
@@ -217,7 +255,7 @@ export async function executeExceptionFilters(filters, exception, context) {
217
255
  */
218
256
  let HttpWynkExceptionFilter = class HttpWynkExceptionFilter {
219
257
  catch(exception, context) {
220
- const response = context.getResponse();
258
+ const _response = context.getResponse();
221
259
  const status = exception.getStatus();
222
260
  return {
223
261
  statusCode: status,
@@ -235,7 +273,7 @@ export { HttpWynkExceptionFilter };
235
273
  */
236
274
  let AllExceptions = class AllExceptions {
237
275
  catch(exception, context) {
238
- const response = context.getResponse();
276
+ const _response = context.getResponse();
239
277
  if (exception instanceof HttpException) {
240
278
  const status = exception.getStatus();
241
279
  return {
@@ -276,7 +314,7 @@ export { AllExceptions };
276
314
  */
277
315
  export class AuthenticationException {
278
316
  catch(exception, context) {
279
- const response = context.getResponse();
317
+ const _response = context.getResponse();
280
318
  const request = context.getRequest();
281
319
  return {
282
320
  statusCode: exception.statusCode,
@@ -307,7 +345,7 @@ export class AuthenticationException {
307
345
  */
308
346
  export class AuthorizationException {
309
347
  catch(exception, context) {
310
- const response = context.getResponse();
348
+ const _response = context.getResponse();
311
349
  const request = context.getRequest();
312
350
  return {
313
351
  statusCode: exception.statusCode,
@@ -329,7 +367,7 @@ export class AuthorizationException {
329
367
  */
330
368
  export class RateLimitException {
331
369
  catch(exception, context) {
332
- const response = context.getResponse();
370
+ const _response = context.getResponse();
333
371
  const request = context.getRequest();
334
372
  // Don't catch HttpException or its subclasses
335
373
  if (exception instanceof HttpException) {
@@ -355,7 +393,7 @@ export class RateLimitException {
355
393
  */
356
394
  export class BusinessLogicException {
357
395
  catch(exception, context) {
358
- const response = context.getResponse();
396
+ const _response = context.getResponse();
359
397
  const request = context.getRequest();
360
398
  // Don't catch HttpException or its subclasses
361
399
  if (exception instanceof HttpException) {
@@ -90,4 +90,3 @@ export declare class SimpleErrorFormatter implements ErrorFormatter {
90
90
  export declare class DetailedErrorFormatter implements ErrorFormatter {
91
91
  format(error: any): any;
92
92
  }
93
- //# sourceMappingURL=formatter.decorators.d.ts.map