wynkjs 1.0.7 → 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.
- package/README.md +76 -0
- package/dist/common/http-status.enum.d.ts +129 -0
- package/dist/common/http-status.enum.js +135 -0
- package/dist/cors.d.ts +0 -1
- package/dist/cors.js +2 -2
- package/dist/database.d.ts +0 -1
- package/dist/decorators/database.decorators.d.ts +0 -1
- package/dist/decorators/database.decorators.js +2 -2
- package/dist/decorators/di.decorators.d.ts +13 -0
- package/dist/decorators/di.decorators.js +28 -0
- package/dist/decorators/exception.decorators.d.ts +34 -1
- package/dist/decorators/exception.decorators.js +44 -6
- package/dist/decorators/formatter.decorators.d.ts +0 -1
- package/dist/decorators/guard.decorators.d.ts +22 -3
- package/dist/decorators/guard.decorators.js +1 -0
- package/dist/decorators/http.decorators.d.ts +30 -1
- package/dist/decorators/http.decorators.js +25 -4
- package/dist/decorators/interceptor.advanced.d.ts +0 -1
- package/dist/decorators/interceptor.decorators.d.ts +40 -3
- package/dist/decorators/metadata.decorators.d.ts +71 -0
- package/dist/decorators/metadata.decorators.js +134 -0
- package/dist/decorators/param.decorators.d.ts +27 -2
- package/dist/decorators/pipe.advanced.d.ts +19 -26
- package/dist/decorators/pipe.advanced.js +84 -54
- package/dist/decorators/pipe.decorators.d.ts +76 -12
- package/dist/decorators/pipe.decorators.js +55 -8
- package/dist/dto.d.ts +0 -1
- package/dist/factory.d.ts +270 -20
- package/dist/factory.js +284 -68
- package/dist/filters/exception.filters.d.ts +0 -1
- package/dist/filters/exception.filters.js +3 -3
- package/dist/global-prefix.d.ts +2 -3
- package/dist/global-prefix.js +4 -6
- package/dist/index.d.ts +13 -1
- package/dist/index.js +13 -0
- package/dist/interfaces/interceptor.interface.d.ts +0 -1
- package/dist/interfaces/lifecycle.interface.d.ts +53 -0
- package/dist/interfaces/lifecycle.interface.js +1 -0
- package/dist/module.d.ts +53 -0
- package/dist/module.js +35 -0
- package/dist/pipes/validation.pipe.d.ts +1 -2
- package/dist/pipes/validation.pipe.js +1 -1
- package/dist/plugins/compression.d.ts +0 -1
- package/dist/plugins/compression.js +24 -9
- package/dist/request.d.ts +126 -0
- package/dist/request.js +214 -0
- package/dist/response.d.ts +128 -0
- package/dist/response.js +261 -0
- package/dist/schema-registry.d.ts +0 -1
- package/dist/testing/index.d.ts +0 -1
- package/dist/testing/test-utils.d.ts +0 -1
- package/dist/ultra-optimized-handler.d.ts +0 -1
- package/dist/ultra-optimized-handler.js +44 -4
- package/package.json +18 -6
- package/dist/cors.d.ts.map +0 -1
- package/dist/database.d.ts.map +0 -1
- package/dist/decorators/database.decorators.d.ts.map +0 -1
- package/dist/decorators/exception.advanced.d.ts +0 -457
- package/dist/decorators/exception.advanced.d.ts.map +0 -1
- package/dist/decorators/exception.advanced.js +0 -742
- package/dist/decorators/exception.decorators.d.ts.map +0 -1
- package/dist/decorators/formatter.decorators.d.ts.map +0 -1
- package/dist/decorators/guard.decorators.d.ts.map +0 -1
- package/dist/decorators/http.decorators.d.ts.map +0 -1
- package/dist/decorators/interceptor.advanced.d.ts.map +0 -1
- package/dist/decorators/interceptor.decorators.d.ts.map +0 -1
- package/dist/decorators/param.decorators.d.ts.map +0 -1
- package/dist/decorators/pipe.advanced.d.ts.map +0 -1
- package/dist/decorators/pipe.decorators.d.ts.map +0 -1
- package/dist/dto.d.ts.map +0 -1
- package/dist/factory.d.ts.map +0 -1
- package/dist/filters/exception.filters.d.ts.map +0 -1
- package/dist/global-prefix.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/interfaces/interceptor.interface.d.ts.map +0 -1
- package/dist/optimized-handler.d.ts +0 -31
- package/dist/optimized-handler.d.ts.map +0 -1
- package/dist/optimized-handler.js +0 -180
- package/dist/pipes/validation.pipe.d.ts.map +0 -1
- package/dist/plugins/compression.d.ts.map +0 -1
- package/dist/schema-registry.d.ts.map +0 -1
- package/dist/testing/index.d.ts.map +0 -1
- package/dist/testing/test-utils.d.ts.map +0 -1
- package/dist/ultra-optimized-handler.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -573,6 +573,82 @@ export function myPlugin(options = {}) {
|
|
|
573
573
|
app.use(myPlugin({ option: "value" }));
|
|
574
574
|
```
|
|
575
575
|
|
|
576
|
+
#### Swagger / OpenAPI Documentation
|
|
577
|
+
|
|
578
|
+
**✨ New Feature**: WynkJS can use Elysia's Swagger plugin for automatic API documentation!
|
|
579
|
+
|
|
580
|
+
Since WynkJS is built on top of Elysia, you can use the official `@elysiajs/swagger` plugin to generate interactive API documentation from your WynkJS decorators.
|
|
581
|
+
|
|
582
|
+
```bash
|
|
583
|
+
bun add @elysiajs/swagger
|
|
584
|
+
```
|
|
585
|
+
|
|
586
|
+
```typescript
|
|
587
|
+
import { WynkFactory } from "wynkjs";
|
|
588
|
+
import { swagger } from "@elysiajs/swagger";
|
|
589
|
+
|
|
590
|
+
const app = WynkFactory.create({
|
|
591
|
+
controllers: [UserController, ProductController],
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
const server = await app.build();
|
|
595
|
+
|
|
596
|
+
// Add Swagger documentation
|
|
597
|
+
server.use(
|
|
598
|
+
swagger({
|
|
599
|
+
documentation: {
|
|
600
|
+
info: {
|
|
601
|
+
title: "My API Documentation",
|
|
602
|
+
version: "1.0.0",
|
|
603
|
+
description: "Auto-generated from WynkJS decorators",
|
|
604
|
+
},
|
|
605
|
+
tags: [
|
|
606
|
+
{ name: "users", description: "User management" },
|
|
607
|
+
{ name: "products", description: "Product catalog" },
|
|
608
|
+
],
|
|
609
|
+
},
|
|
610
|
+
path: "/docs",
|
|
611
|
+
})
|
|
612
|
+
);
|
|
613
|
+
|
|
614
|
+
server.listen(3000);
|
|
615
|
+
// 📚 Visit: http://localhost:3000/docs
|
|
616
|
+
```
|
|
617
|
+
|
|
618
|
+
**What gets auto-documented:**
|
|
619
|
+
|
|
620
|
+
✅ All HTTP routes (@Get, @Post, etc.)
|
|
621
|
+
✅ Query parameters (from DTOs)
|
|
622
|
+
✅ Request body schemas (from DTOs)
|
|
623
|
+
✅ Path parameters (from DTOs)
|
|
624
|
+
✅ Validation rules (min, max, format)
|
|
625
|
+
✅ JWT Authentication support
|
|
626
|
+
|
|
627
|
+
**With JWT Authentication:**
|
|
628
|
+
|
|
629
|
+
```typescript
|
|
630
|
+
server.use(
|
|
631
|
+
swagger({
|
|
632
|
+
documentation: {
|
|
633
|
+
info: { title: "Secure API", version: "1.0.0" },
|
|
634
|
+
components: {
|
|
635
|
+
securitySchemes: {
|
|
636
|
+
bearerAuth: {
|
|
637
|
+
type: "http",
|
|
638
|
+
scheme: "bearer",
|
|
639
|
+
bearerFormat: "JWT",
|
|
640
|
+
},
|
|
641
|
+
},
|
|
642
|
+
},
|
|
643
|
+
security: [{ bearerAuth: [] }],
|
|
644
|
+
},
|
|
645
|
+
path: "/docs",
|
|
646
|
+
})
|
|
647
|
+
);
|
|
648
|
+
```
|
|
649
|
+
|
|
650
|
+
📚 See [Swagger Integration Guide](./docs/SWAGGER_INTEGRATION.md) for complete examples and best practices.
|
|
651
|
+
|
|
576
652
|
### �🔒 Authentication with Guards
|
|
577
653
|
|
|
578
654
|
```typescript
|
|
@@ -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
package/dist/cors.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export function setupCors(app, corsOptions) {
|
|
8
8
|
try {
|
|
9
|
-
//
|
|
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 (
|
|
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");
|
package/dist/database.d.ts
CHANGED
|
@@ -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 [
|
|
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 [
|
|
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
|