tspace-spear 1.2.2 → 1.2.4

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 (57) hide show
  1. package/README.md +304 -23
  2. package/dist/lib/core/const/index.d.ts +153 -0
  3. package/dist/lib/core/const/index.js +105 -0
  4. package/dist/lib/core/const/index.js.map +1 -0
  5. package/dist/lib/core/decorators/context.d.ts +16 -9
  6. package/dist/lib/core/decorators/context.js +85 -59
  7. package/dist/lib/core/decorators/context.js.map +1 -1
  8. package/dist/lib/core/decorators/headers.d.ts +2 -2
  9. package/dist/lib/core/decorators/headers.js +1 -1
  10. package/dist/lib/core/decorators/headers.js.map +1 -1
  11. package/dist/lib/core/decorators/methods.d.ts +7 -7
  12. package/dist/lib/core/decorators/methods.js.map +1 -1
  13. package/dist/lib/core/decorators/middleware.d.ts +3 -3
  14. package/dist/lib/core/decorators/middleware.js +2 -2
  15. package/dist/lib/core/decorators/middleware.js.map +1 -1
  16. package/dist/lib/core/decorators/statusCode.d.ts +1 -1
  17. package/dist/lib/core/decorators/statusCode.js.map +1 -1
  18. package/dist/lib/core/decorators/swagger.d.ts +1 -1
  19. package/dist/lib/core/decorators/swagger.js.map +1 -1
  20. package/dist/lib/core/server/express.d.ts +295 -0
  21. package/dist/lib/core/server/express.js +1356 -0
  22. package/dist/lib/core/server/express.js.map +1 -0
  23. package/dist/lib/core/server/fast-router.d.ts +133 -0
  24. package/dist/lib/core/server/fast-router.js +277 -0
  25. package/dist/lib/core/server/fast-router.js.map +1 -0
  26. package/dist/lib/core/server/index.d.ts +43 -36
  27. package/dist/lib/core/server/index.js +300 -426
  28. package/dist/lib/core/server/index.js.map +1 -1
  29. package/dist/lib/core/server/net/index.d.ts +20 -0
  30. package/dist/lib/core/server/net/index.js +393 -0
  31. package/dist/lib/core/server/net/index.js.map +1 -0
  32. package/dist/lib/core/server/parser-factory.d.ts +20 -12
  33. package/dist/lib/core/server/parser-factory.js +283 -196
  34. package/dist/lib/core/server/parser-factory.js.map +1 -1
  35. package/dist/lib/core/server/request.d.ts +2 -0
  36. package/dist/lib/core/server/request.js +7 -0
  37. package/dist/lib/core/server/request.js.map +1 -0
  38. package/dist/lib/core/server/response.d.ts +6 -0
  39. package/dist/lib/core/server/response.js +168 -0
  40. package/dist/lib/core/server/response.js.map +1 -0
  41. package/dist/lib/core/server/router.d.ts +2 -2
  42. package/dist/lib/core/server/router.js +2 -1
  43. package/dist/lib/core/server/router.js.map +1 -1
  44. package/dist/lib/core/server/uWS/index.d.ts +30 -0
  45. package/dist/lib/core/server/uWS/index.js +357 -0
  46. package/dist/lib/core/server/uWS/index.js.map +1 -0
  47. package/dist/lib/core/types/index.d.ts +159 -38
  48. package/dist/lib/core/utils/index.d.ts +12 -0
  49. package/dist/lib/core/utils/index.js +137 -0
  50. package/dist/lib/core/utils/index.js.map +1 -0
  51. package/dist/lib/index.d.ts +3 -3
  52. package/dist/lib/index.js +3 -2
  53. package/dist/lib/index.js.map +1 -1
  54. package/package.json +27 -11
  55. package/dist/tests/benchmark.test.d.ts +0 -1
  56. package/dist/tests/benchmark.test.js +0 -145
  57. package/dist/tests/benchmark.test.js.map +0 -1
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HEADER_CONTENT_TYPES = exports.HTTP_STATUS_MESSAGES = void 0;
4
+ exports.HTTP_STATUS_MESSAGES = {
5
+ 100: 'Continue',
6
+ 101: 'Switching Protocols',
7
+ 102: 'Processing',
8
+ 200: 'OK',
9
+ 201: 'Created',
10
+ 202: 'Accepted',
11
+ 203: 'Non-Authoritative Information',
12
+ 204: 'No Content',
13
+ 205: 'Reset Content',
14
+ 206: 'Partial Content',
15
+ 207: 'Multi-Status',
16
+ 208: 'Already Reported',
17
+ 226: 'IM Used',
18
+ 300: 'Multiple Choices',
19
+ 301: 'Moved Permanently',
20
+ 302: 'Found',
21
+ 303: 'See Other',
22
+ 304: 'Not Modified',
23
+ 305: 'Use Proxy',
24
+ 306: '(Unused)',
25
+ 307: 'Temporary Redirect',
26
+ 308: 'Permanent Redirect',
27
+ 400: 'Bad Request',
28
+ 401: 'Unauthorized',
29
+ 402: 'Payment Required',
30
+ 403: 'Forbidden',
31
+ 404: 'Not Found',
32
+ 405: 'Method Not Allowed',
33
+ 406: 'Not Acceptable',
34
+ 407: 'Proxy Authentication Required',
35
+ 408: 'Request Timeout',
36
+ 409: 'Conflict',
37
+ 410: 'Gone',
38
+ 411: 'Length Required',
39
+ 412: 'Precondition Failed',
40
+ 413: 'Payload Too Large',
41
+ 414: 'URI Too Long',
42
+ 415: 'Unsupported Media Type',
43
+ 416: 'Range Not Satisfiable',
44
+ 417: 'Expectation Failed',
45
+ 418: 'I\'m a teapot',
46
+ 421: 'Misdirected Request',
47
+ 422: 'Unprocessable Entity',
48
+ 423: 'Locked',
49
+ 424: 'Failed Dependency',
50
+ 425: 'Too Early',
51
+ 426: 'Upgrade Required',
52
+ 428: 'Precondition Required',
53
+ 429: 'Too Many Requests',
54
+ 431: 'Request Header Fields Too Large',
55
+ 451: 'Unavailable For Legal Reasons',
56
+ 500: 'Internal Server Error',
57
+ 501: 'Not Implemented',
58
+ 502: 'Bad Gateway',
59
+ 503: 'Service Unavailable',
60
+ 504: 'Gateway Timeout',
61
+ 505: 'HTTP Version Not Supported',
62
+ 506: 'Variant Also Negotiates',
63
+ 507: 'Insufficient Storage',
64
+ 508: 'Loop Detected',
65
+ 510: 'Not Extended',
66
+ 511: 'Network Authentication Required'
67
+ };
68
+ exports.HEADER_CONTENT_TYPES = {
69
+ text: { 'Content-Type': 'text/plain' },
70
+ html: { 'Content-Type': 'text/html' },
71
+ css: { 'Content-Type': 'text/css' },
72
+ js: { 'Content-Type': 'application/javascript' },
73
+ json: { 'Content-Type': 'application/json' },
74
+ form: { 'Content-Type': 'application/x-www-form-urlencoded' },
75
+ multipart: { 'Content-Type': 'multipart/form-data' },
76
+ // images
77
+ png: { 'Content-Type': 'image/png' },
78
+ jpg: { 'Content-Type': 'image/jpeg' },
79
+ jpeg: { 'Content-Type': 'image/jpeg' },
80
+ gif: { 'Content-Type': 'image/gif' },
81
+ webp: { 'Content-Type': 'image/webp' },
82
+ svg: { 'Content-Type': 'image/svg+xml' },
83
+ ico: { 'Content-Type': 'image/x-icon' },
84
+ // documents
85
+ pdf: { 'Content-Type': 'application/pdf' },
86
+ zip: { 'Content-Type': 'application/zip' },
87
+ gzip: { 'Content-Type': 'application/gzip' },
88
+ // video
89
+ mp4: { 'Content-Type': 'video/mp4' },
90
+ webm: { 'Content-Type': 'video/webm' },
91
+ ogg: { 'Content-Type': 'video/ogg' },
92
+ // audio
93
+ mp3: { 'Content-Type': 'audio/mpeg' },
94
+ wav: { 'Content-Type': 'audio/wav' },
95
+ aac: { 'Content-Type': 'audio/aac' },
96
+ oga: { 'Content-Type': 'audio/ogg' },
97
+ // fonts
98
+ woff: { 'Content-Type': 'font/woff' },
99
+ woff2: { 'Content-Type': 'font/woff2' },
100
+ ttf: { 'Content-Type': 'font/ttf' },
101
+ otf: { 'Content-Type': 'font/otf' },
102
+ // binary
103
+ octet: { 'Content-Type': 'application/octet-stream' }
104
+ };
105
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/lib/core/const/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG;IAChC,GAAG,EAAE,UAAU;IACf,GAAG,EAAE,qBAAqB;IAC1B,GAAG,EAAE,YAAY;IACjB,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,UAAU;IACf,GAAG,EAAE,+BAA+B;IACpC,GAAG,EAAE,YAAY;IACjB,GAAG,EAAE,eAAe;IACpB,GAAG,EAAE,iBAAiB;IACtB,GAAG,EAAE,cAAc;IACnB,GAAG,EAAE,kBAAkB;IACvB,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,kBAAkB;IACvB,GAAG,EAAE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Ac,EAAE,WAAW,EAAE;IAEpC,QAAQ;IACR,IAAI,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE;IACrC,KAAK,EAAE,EAAE,cAAc,EAAE,YAAY,EAAE;IACvC,GAAG,EAAE,EAAE,cAAc,EAAE,UAAU,EAAE;IACnC,GAAG,EAAE,EAAE,cAAc,EAAE,UAAU,EAAE;IAEnC,SAAS;IACT,KAAK,EAAE,EAAE,cAAc,EAAE,0BAA0B,EAAE;CAC7C,CAAA"}
@@ -1,3 +1,10 @@
1
+ import { type T } from '../types';
2
+ export declare function createDtoDecorator(validator: (ctx: T.Context) => void | Promise<void>, onError?: (ctx: T.Context, error: any) => any): MethodDecorator;
3
+ export declare function createContextDecorator(hook: (ctx: T.Context, next: T.NextFunction, meta: {
4
+ target: any;
5
+ key: string | symbol;
6
+ descriptor: PropertyDescriptor;
7
+ }) => any | Promise<any>): MethodDecorator;
1
8
  /**
2
9
  * Extract specific fields from `ctx.body`.
3
10
  *
@@ -16,7 +23,7 @@
16
23
  * @param {...string} bodyParms - Body field names to extract.
17
24
  * @returns {MethodDecorator}
18
25
  */
19
- export declare const Body: (...bodyParms: string[]) => Function;
26
+ export declare const Body: (...keys: string[]) => MethodDecorator;
20
27
  /**
21
28
  * Extract specific uploaded files from `ctx.files`.
22
29
  *
@@ -31,10 +38,10 @@ export declare const Body: (...bodyParms: string[]) => Function;
31
38
  * }
32
39
  * ```
33
40
  *
34
- * @param {...string} filesParms - File field names to extract.
41
+ * @param {...string} keys - File field names to extract.
35
42
  * @returns {MethodDecorator}
36
43
  */
37
- export declare const Files: (...filesParms: string[]) => Function;
44
+ export declare const Files: (...keys: string[]) => MethodDecorator;
38
45
  /**
39
46
  * Extract specific route parameters from `ctx.params`.
40
47
  *
@@ -49,10 +56,10 @@ export declare const Files: (...filesParms: string[]) => Function;
49
56
  * }
50
57
  * ```
51
58
  *
52
- * @param {...string} paramsData - Route parameter names to extract.
59
+ * @param {...string} keys - Route parameter names to extract.
53
60
  * @returns {MethodDecorator}
54
61
  */
55
- export declare const Params: (...paramsData: string[]) => Function;
62
+ export declare const Params: (...keys: string[]) => MethodDecorator;
56
63
  /**
57
64
  * Extract specific query parameters from `ctx.query`.
58
65
  *
@@ -67,10 +74,10 @@ export declare const Params: (...paramsData: string[]) => Function;
67
74
  * }
68
75
  * ```
69
76
  *
70
- * @param {...string} queryParms - Query parameter names to extract.
77
+ * @param {...string} keys - Query parameter names to extract.
71
78
  * @returns {MethodDecorator}
72
79
  */
73
- export declare const Query: (...queryParms: string[]) => Function;
80
+ export declare const Query: (...keys: string[]) => MethodDecorator;
74
81
  /**
75
82
  * Extract specific cookies from `ctx.cookies`.
76
83
  *
@@ -85,7 +92,7 @@ export declare const Query: (...queryParms: string[]) => Function;
85
92
  * }
86
93
  * ```
87
94
  *
88
- * @param {...string} cookiesParms - Cookie names to extract.
95
+ * @param {...string} keys - Cookie names to extract.
89
96
  * @returns {MethodDecorator}
90
97
  */
91
- export declare const Cookies: (...cookiesParms: string[]) => Function;
98
+ export declare const Cookies: (...keys: string[]) => MethodDecorator;
@@ -1,6 +1,57 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Cookies = exports.Query = exports.Params = exports.Files = exports.Body = void 0;
4
+ exports.createDtoDecorator = createDtoDecorator;
5
+ exports.createContextDecorator = createContextDecorator;
6
+ function createDtoDecorator(validator, onError) {
7
+ return (_target, _key, descriptor) => {
8
+ const original = descriptor.value;
9
+ descriptor.value = async function (ctx, next) {
10
+ try {
11
+ await validator(ctx);
12
+ return await original.call(this, ctx, next);
13
+ }
14
+ catch (err) {
15
+ if (onError) {
16
+ return onError(ctx, err);
17
+ }
18
+ let message = err?.message ?? "Bad Request";
19
+ let issues = err.issues ?? [];
20
+ let status = 400;
21
+ if (err.name === "ZodError") {
22
+ const zodIssues = err.issues
23
+ .map((i) => ({
24
+ path: i.path.join("."),
25
+ message: i.message,
26
+ }));
27
+ message = "Validation failed";
28
+ issues = zodIssues;
29
+ status = 422;
30
+ }
31
+ return ctx.res.status(status).json({
32
+ message,
33
+ issues,
34
+ });
35
+ }
36
+ };
37
+ return descriptor;
38
+ };
39
+ }
40
+ function createContextDecorator(hook) {
41
+ return (target, key, descriptor) => {
42
+ const original = descriptor.value;
43
+ descriptor.value = async function (ctx, next) {
44
+ return await hook(ctx, async () => {
45
+ return await original.call(this, ctx, next);
46
+ }, {
47
+ target,
48
+ key,
49
+ descriptor,
50
+ });
51
+ };
52
+ return descriptor;
53
+ };
54
+ }
4
55
  /**
5
56
  * Extract specific fields from `ctx.body`.
6
57
  *
@@ -19,17 +70,12 @@ exports.Cookies = exports.Query = exports.Params = exports.Files = exports.Body
19
70
  * @param {...string} bodyParms - Body field names to extract.
20
71
  * @returns {MethodDecorator}
21
72
  */
22
- const Body = (...bodyParms) => {
23
- return function (target, key, descriptor) {
24
- const originalMethod = descriptor.value;
25
- descriptor.value = async function (ctx, next) {
26
- const q = ctx?.body ?? {};
27
- const body = bodyParms.reduce((acc, key) => (q[key] != null ? { ...acc, [key]: q[key] } : acc), {});
28
- ctx.body = Object.keys(body).length ? body : {};
29
- return await originalMethod.call(this, ctx, next);
30
- };
31
- return descriptor;
32
- };
73
+ const Body = (...keys) => {
74
+ return createContextDecorator(async (ctx, next) => {
75
+ const body = ctx.body;
76
+ ctx.body = keys.reduce((prev, curr) => (body[curr] != null ? { ...prev, [curr]: body[curr] } : prev), {});
77
+ return await next();
78
+ });
33
79
  };
34
80
  exports.Body = Body;
35
81
  /**
@@ -46,20 +92,15 @@ exports.Body = Body;
46
92
  * }
47
93
  * ```
48
94
  *
49
- * @param {...string} filesParms - File field names to extract.
95
+ * @param {...string} keys - File field names to extract.
50
96
  * @returns {MethodDecorator}
51
97
  */
52
- const Files = (...filesParms) => {
53
- return function (target, key, descriptor) {
54
- const originalMethod = descriptor.value;
55
- descriptor.value = async function (ctx, next) {
56
- const q = ctx?.files ?? {};
57
- const files = filesParms.reduce((acc, key) => (q[key] != null ? { ...acc, [key]: q[key] } : acc), {});
58
- ctx.files = Object.keys(files).length ? files : {};
59
- return await originalMethod.call(this, ctx, next);
60
- };
61
- return descriptor;
62
- };
98
+ const Files = (...keys) => {
99
+ return createContextDecorator(async (ctx, next) => {
100
+ const files = ctx.files;
101
+ ctx.files = keys.reduce((prev, curr) => (files[curr] != null ? { ...prev, [curr]: files[curr] } : prev), {});
102
+ return await next();
103
+ });
63
104
  };
64
105
  exports.Files = Files;
65
106
  /**
@@ -76,20 +117,15 @@ exports.Files = Files;
76
117
  * }
77
118
  * ```
78
119
  *
79
- * @param {...string} paramsData - Route parameter names to extract.
120
+ * @param {...string} keys - Route parameter names to extract.
80
121
  * @returns {MethodDecorator}
81
122
  */
82
- const Params = (...paramsData) => {
83
- return function (target, key, descriptor) {
84
- const originalMethod = descriptor.value;
85
- descriptor.value = async function (ctx, next) {
86
- const q = ctx?.params ?? {};
87
- const params = paramsData.reduce((acc, key) => (q[key] != null ? { ...acc, [key]: q[key] } : acc), {});
88
- ctx.params = Object.keys(params).length ? params : {};
89
- return await originalMethod.call(this, ctx, next);
90
- };
91
- return descriptor;
92
- };
123
+ const Params = (...keys) => {
124
+ return createContextDecorator(async (ctx, next) => {
125
+ const params = ctx.params;
126
+ ctx.params = keys.reduce((prev, curr) => (params[curr] != null ? { ...prev, [curr]: params[curr] } : prev), {});
127
+ return await next();
128
+ });
93
129
  };
94
130
  exports.Params = Params;
95
131
  /**
@@ -106,20 +142,15 @@ exports.Params = Params;
106
142
  * }
107
143
  * ```
108
144
  *
109
- * @param {...string} queryParms - Query parameter names to extract.
145
+ * @param {...string} keys - Query parameter names to extract.
110
146
  * @returns {MethodDecorator}
111
147
  */
112
- const Query = (...queryParms) => {
113
- return function (target, key, descriptor) {
114
- const originalMethod = descriptor.value;
115
- descriptor.value = async function (ctx, next) {
116
- const q = ctx?.query ?? {};
117
- const query = queryParms.reduce((acc, key) => (q[key] != null ? { ...acc, [key]: q[key] } : acc), {});
118
- ctx.query = Object.keys(query).length ? query : {};
119
- return await originalMethod.call(this, ctx, next);
120
- };
121
- return descriptor;
122
- };
148
+ const Query = (...keys) => {
149
+ return createContextDecorator(async (ctx, next) => {
150
+ const query = ctx.query;
151
+ ctx.query = keys.reduce((prev, curr) => (query[curr] != null ? { ...prev, [curr]: query[curr] } : prev), {});
152
+ return await next();
153
+ });
123
154
  };
124
155
  exports.Query = Query;
125
156
  /**
@@ -136,20 +167,15 @@ exports.Query = Query;
136
167
  * }
137
168
  * ```
138
169
  *
139
- * @param {...string} cookiesParms - Cookie names to extract.
170
+ * @param {...string} keys - Cookie names to extract.
140
171
  * @returns {MethodDecorator}
141
172
  */
142
- const Cookies = (...cookiesParms) => {
143
- return function (target, key, descriptor) {
144
- const originalMethod = descriptor.value;
145
- descriptor.value = async function (ctx, next) {
146
- const q = ctx?.cookies ?? {};
147
- const cookies = cookiesParms.reduce((acc, key) => (q[key] != null ? { ...acc, [key]: q[key] } : acc), {});
148
- ctx.cookies = Object.keys(cookies).length ? cookies : {};
149
- return await originalMethod.call(this, ctx, next);
150
- };
151
- return descriptor;
152
- };
173
+ const Cookies = (...keys) => {
174
+ return createContextDecorator(async (ctx, next) => {
175
+ const cookies = ctx.cookies;
176
+ ctx.cookies = keys.reduce((prev, curr) => (cookies[curr] != null ? { ...prev, [curr]: cookies[curr] } : prev), {});
177
+ return await next();
178
+ });
153
179
  };
154
180
  exports.Cookies = Cookies;
155
181
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../../../src/lib/core/decorators/context.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;GAiBG;AACI,MAAM,IAAI,GAAG,CAAC,GAAG,SAAmB,EAAY,EAAE;IACrD,OAAO,UAAU,MAAW,EAAE,GAAW,EAAE,UAA8B;QACrE,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC;QAExC,UAAU,CAAC,KAAK,GAAG,KAAK,WAAW,GAAc,EAAE,IAAo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G,CAAC,GAAG,IAAc,EAAmB,EAAE;IAC1D,OAAO,sBAAsB,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAC9C,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC;QAE5B,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CACrB,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EACnF,EAAE,CACL,CAAC;QAEF,OAAO,MAAM,IAAI,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAXW,QAAA,OAAO,WAWlB"}
@@ -26,6 +26,6 @@ import { OutgoingHttpHeaders } from 'http';
26
26
  *
27
27
  * @param {number} statusCode - HTTP status code to send with the response.
28
28
  * @param {OutgoingHttpHeaders} contentType - Response headers to set.
29
- * @returns {Function}
29
+ * @returns {MethodDecorator}
30
30
  */
31
- export declare const WriteHeader: (statusCode: number, contentType: OutgoingHttpHeaders) => Function;
31
+ export declare const WriteHeader: (statusCode: number, contentType: OutgoingHttpHeaders) => MethodDecorator;
@@ -28,7 +28,7 @@ exports.WriteHeader = void 0;
28
28
  *
29
29
  * @param {number} statusCode - HTTP status code to send with the response.
30
30
  * @param {OutgoingHttpHeaders} contentType - Response headers to set.
31
- * @returns {Function}
31
+ * @returns {MethodDecorator}
32
32
  */
33
33
  const WriteHeader = (statusCode, contentType) => {
34
34
  return (target, key, descriptor) => {
@@ -1 +1 @@
1
- {"version":3,"file":"headers.js","sourceRoot":"","sources":["../../../../src/lib/core/decorators/headers.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACI,MAAM,WAAW,GAAG,CAAC,UAAkB,EAAE,WAAgC,EAAY,EAAE;IAC5F,OAAO,CAAC,MAAW,EAAE,GAAW,EAAE,UAA8B,EAAE,EAAE;QAClE,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC;QAExC,UAAU,CAAC,KAAK,GAAG,KAAK,WAAW,GAAc,EAAE,IAAoB;YACrE,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC;YAChD,OAAO,MAAM,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QACpD,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC,CAAC;AAXW,QAAA,WAAW,eAWtB"}
1
+ {"version":3,"file":"headers.js","sourceRoot":"","sources":["../../../../src/lib/core/decorators/headers.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACI,MAAM,WAAW,GAAG,CAAC,UAAkB,EAAE,WAAgC,EAAmB,EAAE;IACnG,OAAO,CAAC,MAAW,EAAE,GAAQ,EAAE,UAA8B,EAAE,EAAE;QAC/D,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC;QAExC,UAAU,CAAC,KAAK,GAAG,KAAK,WAAW,GAAc,EAAE,IAAoB;YACrE,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC;YAChD,OAAO,MAAM,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QACpD,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC,CAAC;AAXW,QAAA,WAAW,eAWtB"}
@@ -9,7 +9,7 @@
9
9
  * }
10
10
  * ```
11
11
  */
12
- export declare const Get: (path: `/${string}`) => (target: any, propertyKey: any) => void;
12
+ export declare const Get: (path: `/${string}`) => MethodDecorator;
13
13
  /**
14
14
  * Maps a controller method to an HTTP POST route.
15
15
  *
@@ -21,7 +21,7 @@ export declare const Get: (path: `/${string}`) => (target: any, propertyKey: any
21
21
  * }
22
22
  * ```
23
23
  */
24
- export declare const Post: (path: `/${string}`) => (target: any, propertyKey: any) => void;
24
+ export declare const Post: (path: `/${string}`) => MethodDecorator;
25
25
  /**
26
26
  * Maps a controller method to an HTTP PUT route.
27
27
  *
@@ -33,7 +33,7 @@ export declare const Post: (path: `/${string}`) => (target: any, propertyKey: an
33
33
  * async update(ctx: T.Context) {}
34
34
  * ```
35
35
  */
36
- export declare const Put: (path: `/${string}`) => (target: any, propertyKey: any) => void;
36
+ export declare const Put: (path: `/${string}`) => MethodDecorator;
37
37
  /**
38
38
  * Maps a controller method to an HTTP PATCH route.
39
39
  *
@@ -45,7 +45,7 @@ export declare const Put: (path: `/${string}`) => (target: any, propertyKey: any
45
45
  * async patch(ctx: T.Context) {}
46
46
  * ```
47
47
  */
48
- export declare const Patch: (path: `/${string}`) => (target: any, propertyKey: any) => void;
48
+ export declare const Patch: (path: `/${string}`) => MethodDecorator;
49
49
  /**
50
50
  * Maps a controller method to an HTTP DELETE route.
51
51
  *
@@ -55,7 +55,7 @@ export declare const Patch: (path: `/${string}`) => (target: any, propertyKey: a
55
55
  * async remove(ctx: T.Context) {}
56
56
  * ```
57
57
  */
58
- export declare const Delete: (path: `/${string}`) => (target: any, propertyKey: any) => void;
58
+ export declare const Delete: (path: `/${string}`) => MethodDecorator;
59
59
  /**
60
60
  * Maps a controller method to an HTTP HEAD route.
61
61
  *
@@ -67,7 +67,7 @@ export declare const Delete: (path: `/${string}`) => (target: any, propertyKey:
67
67
  * async health(ctx: T.Context) {}
68
68
  * ```
69
69
  */
70
- export declare const Head: (path: `/${string}`) => (target: any, propertyKey: any) => void;
70
+ export declare const Head: (path: `/${string}`) => MethodDecorator;
71
71
  /**
72
72
  * Maps a controller method to an HTTP OPTIONS route.
73
73
  *
@@ -79,4 +79,4 @@ export declare const Head: (path: `/${string}`) => (target: any, propertyKey: an
79
79
  * async options(ctx: T.Context) {}
80
80
  * ```
81
81
  */
82
- export declare const Options: (path: `/${string}`) => (target: any, propertyKey: any) => void;
82
+ export declare const Options: (path: `/${string}`) => MethodDecorator;
@@ -1 +1 @@
1
- {"version":3,"file":"methods.js","sourceRoot":"","sources":["../../../../src/lib/core/decorators/methods.ts"],"names":[],"mappings":";;;AAEA,MAAM,eAAe,GAAG,CAAC,MAAgB,EAAE,EAAE;IAC3C,OAAO,CAAC,IAAkB,EAAE,EAAE;QAC5B,OAAO,CAAC,MAAU,EAAE,WAAe,EAAE,EAAE;YACrC,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC;YAEtC,MAAM,OAAO,GAAe,OAAO,CAAC,WAAW,CAAC,SAAS,EAAE,UAAU,CAAC;gBACpE,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,SAAS,EAAE,UAAU,CAAC;gBAC5C,CAAC,CAAC,EAAE,CAAC;YAEP,OAAO,CAAC,IAAI,CAAC;gBACX,MAAM;gBACN,IAAI;gBACJ,OAAO,EAAE,WAAW;aACrB,CAAC,CAAC;YAEH,OAAO,CAAC,cAAc,CAAC,SAAS,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;QACzD,CAAC,CAAA;IACH,CAAC,CAAA;AACH,CAAC,CAAA;AAED;;;;;;;;;;GAUG;AACU,QAAA,GAAG,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;AAE1C;;;;;;;;;;GAUG;AACU,QAAA,IAAI,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;AAE5C;;;;;;;;;;GAUG;AACU,QAAA,GAAG,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;AAE1C;;;;;;;;;;GAUG;AACU,QAAA,KAAK,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;AAE9C;;;;;;;;GAQG;AACU,QAAA,MAAM,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;A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,IAAI,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;AAE5C;;;;;;;;;;GAUG;AACU,QAAA,OAAO,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC"}
@@ -25,7 +25,7 @@ import { T } from '../types';
25
25
  * Example middleware:
26
26
  *
27
27
  * ```ts
28
- * const authMiddleware: T.RequestFunction = (ctx, next) => {
28
+ * const authMiddleware: T.ContextHandler = (ctx, next) => {
29
29
  * if (!ctx.user) {
30
30
  * return next(new Error("Unauthorized"));
31
31
  * }
@@ -33,7 +33,7 @@ import { T } from '../types';
33
33
  * };
34
34
  * ```
35
35
  *
36
- * @param {T.RequestFunction} middleware - Middleware function to execute before the route handler.
36
+ * @param {T.ContextHandler} middleware - Middleware function to execute before the route handler.
37
37
  * @returns {MethodDecorator}
38
38
  */
39
- export declare const Middleware: (middleware: T.RequestFunction) => Function;
39
+ export declare const Middleware: (middleware: T.ContextHandler) => MethodDecorator;
@@ -27,7 +27,7 @@ exports.Middleware = void 0;
27
27
  * Example middleware:
28
28
  *
29
29
  * ```ts
30
- * const authMiddleware: T.RequestFunction = (ctx, next) => {
30
+ * const authMiddleware: T.ContextHandler = (ctx, next) => {
31
31
  * if (!ctx.user) {
32
32
  * return next(new Error("Unauthorized"));
33
33
  * }
@@ -35,7 +35,7 @@ exports.Middleware = void 0;
35
35
  * };
36
36
  * ```
37
37
  *
38
- * @param {T.RequestFunction} middleware - Middleware function to execute before the route handler.
38
+ * @param {T.ContextHandler} middleware - Middleware function to execute before the route handler.
39
39
  * @returns {MethodDecorator}
40
40
  */
41
41
  const Middleware = (middleware) => {
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../../src/lib/core/decorators/middleware.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACI,MAAM,UAAU,GAAG,CAAC,UAA6B,EAAY,EAAE;IAEpE,OAAO,CAAC,MAAW,EAAE,GAAW,EAAE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IAAI,CAAC,GAAG,CAAC,CAAC;oBACnB,CAAC;oBAED,OAAO,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;gBAC9C,CAAC,CAAC,CAAC;YAEL,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC;YACrB,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC;AAvBW,QAAA,UAAU,cAuBrB"}
@@ -23,4 +23,4 @@ import { type T } from '../types';
23
23
  * @param {T.StatusCode} statusCode - HTTP status code to send with the response.
24
24
  * @returns {MethodDecorator}
25
25
  */
26
- export declare const StatusCode: (statusCode: T.StatusCode) => Function;
26
+ export declare const StatusCode: (statusCode: T.StatusCode) => MethodDecorator;
@@ -1 +1 @@
1
- {"version":3,"file":"statusCode.js","sourceRoot":"","sources":["../../../../src/lib/core/decorators/statusCode.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACI,MAAM,UAAU,GAAG,CAAC,UAAwB,EAAY,EAAE;IAC7D,OAAO,CAAC,MAAW,EAAE,GAAW,EAAE,UAA8B,EAAE,EAAE;QAChE,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC;QAExC,MAAM,IAAI,GAAG,UAAU,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC;QAE1E,UAAU,CAAC,KAAK,GAAG,KAAK,WAAW,GAAc,EAAE,IAAoB;YACnE,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC,CAAC;YAChE,OAAO,MAAM,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QACtD,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACtB,CAAC,CAAC;AACN,CAAC,CAAC;AAbW,QAAA,UAAU,cAarB"}
1
+ {"version":3,"file":"statusCode.js","sourceRoot":"","sources":["../../../../src/lib/core/decorators/statusCode.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACI,MAAM,UAAU,GAAG,CAAC,UAAwB,EAAmB,EAAE;IACpE,OAAO,CAAC,MAAW,EAAE,GAAQ,EAAE,UAA8B,EAAE,EAAE;QAC7D,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC;QAExC,MAAM,IAAI,GAAG,UAAU,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC;QAE1E,UAAU,CAAC,KAAK,GAAG,KAAK,WAAW,GAAc,EAAE,IAAoB;YACnE,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC,CAAC;YAChE,OAAO,MAAM,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QACtD,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACtB,CAAC,CAAC;AACN,CAAC,CAAC;AAbW,QAAA,UAAU,cAarB"}
@@ -33,4 +33,4 @@ import { type T } from "../types";
33
33
  * @param {T.Swagger.Spec} data - Swagger/OpenAPI specification for the route.
34
34
  * @returns {MethodDecorator}
35
35
  */
36
- export declare const Swagger: (data: T.Swagger.Spec) => (target: any, propertyKey: any) => void;
36
+ export declare const Swagger: (data: T.Swagger.Spec) => MethodDecorator;
@@ -1 +1 @@
1
- {"version":3,"file":"swagger.js","sourceRoot":"","sources":["../../../../src/lib/core/decorators/swagger.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;G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