@heliosjs/core 1.0.2

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 (152) hide show
  1. package/README.md +540 -0
  2. package/dist/Controller.d.ts +54 -0
  3. package/dist/Controller.js +168 -0
  4. package/dist/Controller.js.map +1 -0
  5. package/dist/Endpoint.d.ts +73 -0
  6. package/dist/Endpoint.js +126 -0
  7. package/dist/Endpoint.js.map +1 -0
  8. package/dist/constants.d.ts +25 -0
  9. package/dist/constants.js +34 -0
  10. package/dist/constants.js.map +1 -0
  11. package/dist/decorators.d.ts +94 -0
  12. package/dist/decorators.js +107 -0
  13. package/dist/decorators.js.map +1 -0
  14. package/dist/index.d.ts +11 -0
  15. package/dist/index.js +29 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/types/core/common.d.ts +44 -0
  18. package/dist/types/core/common.js +15 -0
  19. package/dist/types/core/common.js.map +1 -0
  20. package/dist/types/core/controller.d.ts +78 -0
  21. package/dist/types/core/controller.js +3 -0
  22. package/dist/types/core/controller.js.map +1 -0
  23. package/dist/types/core/cors.d.ts +10 -0
  24. package/dist/types/core/cors.js +3 -0
  25. package/dist/types/core/cors.js.map +1 -0
  26. package/dist/types/core/error.d.ts +72 -0
  27. package/dist/types/core/error.js +19 -0
  28. package/dist/types/core/error.js.map +1 -0
  29. package/dist/types/core/index.d.ts +9 -0
  30. package/dist/types/core/index.js +26 -0
  31. package/dist/types/core/index.js.map +1 -0
  32. package/dist/types/core/multipart.d.ts +8 -0
  33. package/dist/types/core/multipart.js +3 -0
  34. package/dist/types/core/multipart.js.map +1 -0
  35. package/dist/types/core/request.d.ts +65 -0
  36. package/dist/types/core/request.js +3 -0
  37. package/dist/types/core/request.js.map +1 -0
  38. package/dist/types/core/response.d.ts +49 -0
  39. package/dist/types/core/response.js +3 -0
  40. package/dist/types/core/response.js.map +1 -0
  41. package/dist/types/core/sanitize.d.ts +8 -0
  42. package/dist/types/core/sanitize.js +3 -0
  43. package/dist/types/core/sanitize.js.map +1 -0
  44. package/dist/types/core/sse.d.ts +37 -0
  45. package/dist/types/core/sse.js +3 -0
  46. package/dist/types/core/sse.js.map +1 -0
  47. package/dist/types/ws/index.d.ts +50 -0
  48. package/dist/types/ws/index.js +3 -0
  49. package/dist/types/ws/index.js.map +1 -0
  50. package/dist/utils/core/controller.d.ts +25 -0
  51. package/dist/utils/core/controller.js +219 -0
  52. package/dist/utils/core/controller.js.map +1 -0
  53. package/dist/utils/core/cors.d.ts +8 -0
  54. package/dist/utils/core/cors.js +128 -0
  55. package/dist/utils/core/cors.js.map +1 -0
  56. package/dist/utils/core/endpoint.d.ts +3 -0
  57. package/dist/utils/core/endpoint.js +28 -0
  58. package/dist/utils/core/endpoint.js.map +1 -0
  59. package/dist/utils/core/error/apperror.d.ts +31 -0
  60. package/dist/utils/core/error/apperror.js +131 -0
  61. package/dist/utils/core/error/apperror.js.map +1 -0
  62. package/dist/utils/core/error/authorizations.d.ts +7 -0
  63. package/dist/utils/core/error/authorizations.js +17 -0
  64. package/dist/utils/core/error/authorizations.js.map +1 -0
  65. package/dist/utils/core/error/base.d.ts +20 -0
  66. package/dist/utils/core/error/base.js +52 -0
  67. package/dist/utils/core/error/base.js.map +1 -0
  68. package/dist/utils/core/error/dependencyFailed.d.ts +7 -0
  69. package/dist/utils/core/error/dependencyFailed.js +17 -0
  70. package/dist/utils/core/error/dependencyFailed.js.map +1 -0
  71. package/dist/utils/core/error/duplicateEntry.d.ts +7 -0
  72. package/dist/utils/core/error/duplicateEntry.js +17 -0
  73. package/dist/utils/core/error/duplicateEntry.js.map +1 -0
  74. package/dist/utils/core/error/forbidden.d.ts +7 -0
  75. package/dist/utils/core/error/forbidden.js +17 -0
  76. package/dist/utils/core/error/forbidden.js.map +1 -0
  77. package/dist/utils/core/error/helpers.d.ts +8 -0
  78. package/dist/utils/core/error/helpers.js +144 -0
  79. package/dist/utils/core/error/helpers.js.map +1 -0
  80. package/dist/utils/core/error/index.d.ts +12 -0
  81. package/dist/utils/core/error/index.js +29 -0
  82. package/dist/utils/core/error/index.js.map +1 -0
  83. package/dist/utils/core/error/invalidState.d.ts +7 -0
  84. package/dist/utils/core/error/invalidState.js +17 -0
  85. package/dist/utils/core/error/invalidState.js.map +1 -0
  86. package/dist/utils/core/error/notfound.d.ts +7 -0
  87. package/dist/utils/core/error/notfound.js +18 -0
  88. package/dist/utils/core/error/notfound.js.map +1 -0
  89. package/dist/utils/core/error/rateLimit.d.ts +7 -0
  90. package/dist/utils/core/error/rateLimit.js +17 -0
  91. package/dist/utils/core/error/rateLimit.js.map +1 -0
  92. package/dist/utils/core/error/serviceUnavailable.d.ts +7 -0
  93. package/dist/utils/core/error/serviceUnavailable.js +17 -0
  94. package/dist/utils/core/error/serviceUnavailable.js.map +1 -0
  95. package/dist/utils/core/error/validation.d.ts +10 -0
  96. package/dist/utils/core/error/validation.js +20 -0
  97. package/dist/utils/core/error/validation.js.map +1 -0
  98. package/dist/utils/core/headers.d.ts +2 -0
  99. package/dist/utils/core/headers.js +10 -0
  100. package/dist/utils/core/headers.js.map +1 -0
  101. package/dist/utils/core/helper.d.ts +6 -0
  102. package/dist/utils/core/helper.js +66 -0
  103. package/dist/utils/core/helper.js.map +1 -0
  104. package/dist/utils/core/index.d.ts +10 -0
  105. package/dist/utils/core/index.js +27 -0
  106. package/dist/utils/core/index.js.map +1 -0
  107. package/dist/utils/core/multipart.d.ts +9 -0
  108. package/dist/utils/core/multipart.js +207 -0
  109. package/dist/utils/core/multipart.js.map +1 -0
  110. package/dist/utils/core/request.d.ts +100 -0
  111. package/dist/utils/core/request.js +218 -0
  112. package/dist/utils/core/request.js.map +1 -0
  113. package/dist/utils/core/response.d.ts +48 -0
  114. package/dist/utils/core/response.js +269 -0
  115. package/dist/utils/core/response.js.map +1 -0
  116. package/dist/utils/core/routeWalker.d.ts +2 -0
  117. package/dist/utils/core/routeWalker.js +115 -0
  118. package/dist/utils/core/routeWalker.js.map +1 -0
  119. package/dist/utils/core/sanitize.d.ts +30 -0
  120. package/dist/utils/core/sanitize.js +134 -0
  121. package/dist/utils/core/sanitize.js.map +1 -0
  122. package/dist/utils/shared/index.d.ts +2 -0
  123. package/dist/utils/shared/index.js +19 -0
  124. package/dist/utils/shared/index.js.map +1 -0
  125. package/dist/utils/shared/parsers.d.ts +11 -0
  126. package/dist/utils/shared/parsers.js +133 -0
  127. package/dist/utils/shared/parsers.js.map +1 -0
  128. package/dist/utils/shared/validate.d.ts +1 -0
  129. package/dist/utils/shared/validate.js +41 -0
  130. package/dist/utils/shared/validate.js.map +1 -0
  131. package/dist/utils/socket/index.d.ts +3 -0
  132. package/dist/utils/socket/index.js +20 -0
  133. package/dist/utils/socket/index.js.map +1 -0
  134. package/dist/utils/socket/server.d.ts +33 -0
  135. package/dist/utils/socket/server.js +218 -0
  136. package/dist/utils/socket/server.js.map +1 -0
  137. package/dist/utils/socket/service.d.ts +20 -0
  138. package/dist/utils/socket/service.js +42 -0
  139. package/dist/utils/socket/service.js.map +1 -0
  140. package/dist/utils/socket/socket.d.ts +16 -0
  141. package/dist/utils/socket/socket.js +33 -0
  142. package/dist/utils/socket/socket.js.map +1 -0
  143. package/dist/utils/sse/index.d.ts +2 -0
  144. package/dist/utils/sse/index.js +19 -0
  145. package/dist/utils/sse/index.js.map +1 -0
  146. package/dist/utils/sse/server.d.ts +14 -0
  147. package/dist/utils/sse/server.js +85 -0
  148. package/dist/utils/sse/server.js.map +1 -0
  149. package/dist/utils/sse/service.d.ts +17 -0
  150. package/dist/utils/sse/service.js +40 -0
  151. package/dist/utils/sse/service.js.map +1 -0
  152. package/package.json +37 -0
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Re-exports core decorators and types related to controllers and endpoints.
3
+ *
4
+ * This module provides centralized exports for controller and endpoint decorators,
5
+ * as well as related types and utility functions used throughout the core framework.
6
+ */
7
+ export * from './Controller';
8
+ export * from './decorators';
9
+ export * from './Endpoint';
10
+ export { AppError, CORSConfig, ErrorCB, InterceptorCB, IRequest, IResponse, MiddlewareCB, MultipartFile, SanitizerConfig, } from './types/core';
11
+ export { SANITIZER } from './utils/core';
package/dist/index.js ADDED
@@ -0,0 +1,29 @@
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
+ exports.SANITIZER = void 0;
18
+ /**
19
+ * Re-exports core decorators and types related to controllers and endpoints.
20
+ *
21
+ * This module provides centralized exports for controller and endpoint decorators,
22
+ * as well as related types and utility functions used throughout the core framework.
23
+ */
24
+ __exportStar(require("./Controller"), exports);
25
+ __exportStar(require("./decorators"), exports);
26
+ __exportStar(require("./Endpoint"), exports);
27
+ var core_1 = require("./utils/core");
28
+ Object.defineProperty(exports, "SANITIZER", { enumerable: true, get: function () { return core_1.SANITIZER; } });
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;GAKG;AACH,+CAA6B;AAC7B,+CAA6B;AAC7B,6CAA2B;AAY3B,qCAAyC;AAAhC,iGAAA,SAAS,OAAA"}
@@ -0,0 +1,44 @@
1
+ import { ServerResponse } from 'http';
2
+ import { AppError } from './error';
3
+ import { IRequest } from './request';
4
+ import { IResponse } from './response';
5
+ export type Router = (req: IRequest, res?: ServerResponse) => Promise<{
6
+ status: number;
7
+ data: any;
8
+ message?: string;
9
+ }>;
10
+ export interface IController {
11
+ handleRequest: Router;
12
+ }
13
+ export type MiddlewareCB = (request: IRequest, response: IResponse, next: (args?: any) => any) => void | Promise<IRequest> | IRequest | Promise<void> | void;
14
+ export type InterceptorCB = (data: any, req?: IRequest, res?: IResponse) => Promise<unknown> | unknown;
15
+ export type ErrorCB = (error: AppError, req?: IRequest, res?: IResponse) => any;
16
+ export type ParamDecoratorType = 'body' | 'params' | 'query' | 'request' | 'headers' | 'cookies' | 'response' | 'multipart' | 'event' | 'context' | 'sse' | 'ws';
17
+ export interface ParamMetadata {
18
+ index: number;
19
+ type: ParamDecoratorType;
20
+ dto?: any;
21
+ name?: string;
22
+ }
23
+ export type ResponseWithStatus = {
24
+ status: number;
25
+ [key: string]: any;
26
+ };
27
+ export declare enum HTTP_METHODS {
28
+ ANY = "ANY",
29
+ GET = "GET",
30
+ POST = "POST",
31
+ PATCH = "PATCH",
32
+ DELETE = "DELETE",
33
+ PUT = "PUT",
34
+ OPTIONS = "OPTIONS",
35
+ HEAD = "HEAD"
36
+ }
37
+ export type Meta = {
38
+ requestUrl: URL;
39
+ method: string;
40
+ requestId: string;
41
+ sourceIp: string;
42
+ userAgent: string;
43
+ startTime: number;
44
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HTTP_METHODS = void 0;
4
+ var HTTP_METHODS;
5
+ (function (HTTP_METHODS) {
6
+ HTTP_METHODS["ANY"] = "ANY";
7
+ HTTP_METHODS["GET"] = "GET";
8
+ HTTP_METHODS["POST"] = "POST";
9
+ HTTP_METHODS["PATCH"] = "PATCH";
10
+ HTTP_METHODS["DELETE"] = "DELETE";
11
+ HTTP_METHODS["PUT"] = "PUT";
12
+ HTTP_METHODS["OPTIONS"] = "OPTIONS";
13
+ HTTP_METHODS["HEAD"] = "HEAD";
14
+ })(HTTP_METHODS || (exports.HTTP_METHODS = HTTP_METHODS = {}));
15
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/types/core/common.ts"],"names":[],"mappings":";;;AAsDA,IAAY,YASX;AATD,WAAY,YAAY;IACtB,2BAAW,CAAA;IACX,2BAAW,CAAA;IACX,6BAAa,CAAA;IACb,+BAAe,CAAA;IACf,iCAAiB,CAAA;IACjB,2BAAW,CAAA;IACX,mCAAmB,CAAA;IACnB,6BAAa,CAAA;AACf,CAAC,EATW,YAAY,4BAAZ,YAAY,QASvB"}
@@ -0,0 +1,78 @@
1
+ import { ServerResponse } from 'http';
2
+ import { ErrorCB, HTTP_METHODS, InterceptorCB, MiddlewareCB } from './common';
3
+ import { CORSConfig } from './cors';
4
+ import { IRequest } from './request';
5
+ import { SanitizerConfig } from './sanitize';
6
+ export type ControllerClass = {
7
+ new (...args: any[]): any;
8
+ };
9
+ export type ControllerMethods = Array<{
10
+ name: string;
11
+ httpMethod: HTTP_METHODS;
12
+ pattern: string;
13
+ middlewares?: MiddlewareCB[];
14
+ }>;
15
+ export type ControllerType = {
16
+ handleRequest?(request: IRequest, response: ServerResponse): Promise<any>;
17
+ ws?: WsControllerHandlers;
18
+ sse?: SeeControllerHandlers;
19
+ new (...args: any[]): any;
20
+ };
21
+ export type ControllerInstance = InstanceType<ControllerType>;
22
+ export type ControllerMetadata = {
23
+ routePrefix: string;
24
+ middlewares: MiddlewareCB[];
25
+ interceptor?: InterceptorCB;
26
+ subControllers: ControllerInstance[];
27
+ errorHandler?: ErrorCB;
28
+ cors?: CORSConfig;
29
+ sanitizers: SanitizerConfig[];
30
+ };
31
+ export interface ControllerConfig {
32
+ prefix: string;
33
+ middlewares?: Array<MiddlewareCB>;
34
+ controllers?: ControllerInstance[];
35
+ interceptor?: InterceptorCB;
36
+ }
37
+ export type RouteContext = {
38
+ controllerInstance: any;
39
+ controllerMeta: ControllerMetadata;
40
+ path: string;
41
+ method: string;
42
+ middlewareChain: MiddlewareCB[];
43
+ interceptorChain: InterceptorCB[];
44
+ corsChain: CORSConfig[];
45
+ errorHandlerChain: ErrorCB[];
46
+ subPath: string;
47
+ sanitizersChain: SanitizerConfig[];
48
+ };
49
+ export type SSE_HANDLER_META = {
50
+ type: string;
51
+ method: string;
52
+ };
53
+ export type HandlerMeta = {
54
+ type: 'connection';
55
+ topic: undefined;
56
+ method: 'onconnect';
57
+ fn: (...args: any[]) => any;
58
+ };
59
+ export type WsHandlerMeta = HandlerMeta & {
60
+ topic?: string;
61
+ };
62
+ export type WsControllerHandlers = {
63
+ handlers: {
64
+ connection: WsHandlerMeta[];
65
+ message: WsHandlerMeta[];
66
+ close: WsHandlerMeta[];
67
+ error: WsHandlerMeta[];
68
+ };
69
+ topics: HandlerMeta[];
70
+ };
71
+ export type SeeControllerHandlers = {
72
+ handlers: {
73
+ connection: HandlerMeta[];
74
+ close: HandlerMeta[];
75
+ error: HandlerMeta[];
76
+ };
77
+ };
78
+ export type NextFunction = (error?: unknown) => void;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/types/core/controller.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ export interface CORSConfig {
2
+ origin?: string | string[] | ((origin: string) => boolean);
3
+ methods?: string[];
4
+ allowedHeaders?: string[];
5
+ exposedHeaders?: string[];
6
+ credentials?: boolean;
7
+ maxAge?: number;
8
+ preflightContinue?: boolean;
9
+ optionsSuccessStatus?: number;
10
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=cors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cors.js","sourceRoot":"","sources":["../../../src/types/core/cors.ts"],"names":[],"mappings":""}
@@ -0,0 +1,72 @@
1
+ import { IRequest } from './request';
2
+ import { IResponse } from './response';
3
+ export declare enum ErrorCode {
4
+ BAD_REQUEST = "BAD_REQUEST",
5
+ UNAUTHORIZED = "UNAUTHORIZED",
6
+ FORBIDDEN = "FORBIDDEN",
7
+ NOT_FOUND = "NOT_FOUND",
8
+ VALIDATION_FAILED = "VALIDATION_FAILED",
9
+ RATE_LIMIT_EXCEEDED = "RATE_LIMIT_EXCEEDED",
10
+ INTERNAL_ERROR = "INTERNAL_ERROR",
11
+ SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE",
12
+ DATABASE_ERROR = "DATABASE_ERROR",
13
+ DUPLICATE_ENTRY = "DUPLICATE_ENTRY",
14
+ INVALID_STATE = "INVALID_STATE",
15
+ DEPENDENCY_FAILED = "DEPENDENCY_FAILED"
16
+ }
17
+ export interface ErrorDetails {
18
+ field?: string;
19
+ value?: any;
20
+ constraint?: string;
21
+ [key: string]: any;
22
+ }
23
+ export interface AppError extends Error {
24
+ code: ErrorCode;
25
+ status: number;
26
+ details?: ErrorDetails[];
27
+ timestamp: Date;
28
+ requestId?: string;
29
+ path?: string;
30
+ method?: string;
31
+ toResponse(): ErrorResponse;
32
+ }
33
+ export interface IValidationError extends AppError {
34
+ code: ErrorCode.VALIDATION_FAILED;
35
+ details?: ErrorDetails[];
36
+ }
37
+ export interface ErrorResponse {
38
+ success: false;
39
+ error: {
40
+ code: ErrorCode;
41
+ status: number;
42
+ message: string;
43
+ details?: ErrorDetails[];
44
+ timestamp: string;
45
+ requestId?: string;
46
+ path?: string;
47
+ };
48
+ }
49
+ export interface ErrorHandlerConfig {
50
+ includeStack?: boolean;
51
+ logErrors?: boolean;
52
+ logStack?: boolean;
53
+ customHandlers?: Record<ErrorCode, (error: AppError) => any>;
54
+ }
55
+ export interface SerializedError {
56
+ type: 'Error' | 'HttpError' | 'AxiosError' | 'Unknown' | 'ValidationError';
57
+ message: string;
58
+ status?: number;
59
+ code?: string;
60
+ stack?: string;
61
+ data?: any;
62
+ original?: any;
63
+ errors?: any[];
64
+ details?: ErrorDetails[];
65
+ }
66
+ export interface ErrorHandlerConfig {
67
+ includeStack?: boolean;
68
+ logErrors?: boolean;
69
+ logStack?: boolean;
70
+ customHandlers?: Record<ErrorCode, (error: AppError) => any>;
71
+ }
72
+ export type ErorrHandler = (error: Error, req: IRequest, response: IResponse) => any;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrorCode = void 0;
4
+ var ErrorCode;
5
+ (function (ErrorCode) {
6
+ ErrorCode["BAD_REQUEST"] = "BAD_REQUEST";
7
+ ErrorCode["UNAUTHORIZED"] = "UNAUTHORIZED";
8
+ ErrorCode["FORBIDDEN"] = "FORBIDDEN";
9
+ ErrorCode["NOT_FOUND"] = "NOT_FOUND";
10
+ ErrorCode["VALIDATION_FAILED"] = "VALIDATION_FAILED";
11
+ ErrorCode["RATE_LIMIT_EXCEEDED"] = "RATE_LIMIT_EXCEEDED";
12
+ ErrorCode["INTERNAL_ERROR"] = "INTERNAL_ERROR";
13
+ ErrorCode["SERVICE_UNAVAILABLE"] = "SERVICE_UNAVAILABLE";
14
+ ErrorCode["DATABASE_ERROR"] = "DATABASE_ERROR";
15
+ ErrorCode["DUPLICATE_ENTRY"] = "DUPLICATE_ENTRY";
16
+ ErrorCode["INVALID_STATE"] = "INVALID_STATE";
17
+ ErrorCode["DEPENDENCY_FAILED"] = "DEPENDENCY_FAILED";
18
+ })(ErrorCode || (exports.ErrorCode = ErrorCode = {}));
19
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/types/core/error.ts"],"names":[],"mappings":";;;AAGA,IAAY,SAaX;AAbD,WAAY,SAAS;IACnB,wCAA2B,CAAA;IAC3B,0CAA6B,CAAA;IAC7B,oCAAuB,CAAA;IACvB,oCAAuB,CAAA;IACvB,oDAAuC,CAAA;IACvC,wDAA2C,CAAA;IAC3C,8CAAiC,CAAA;IACjC,wDAA2C,CAAA;IAC3C,8CAAiC,CAAA;IACjC,gDAAmC,CAAA;IACnC,4CAA+B,CAAA;IAC/B,oDAAuC,CAAA;AACzC,CAAC,EAbW,SAAS,yBAAT,SAAS,QAapB"}
@@ -0,0 +1,9 @@
1
+ export * from './common';
2
+ export * from './controller';
3
+ export * from './cors';
4
+ export * from './error';
5
+ export * from './multipart';
6
+ export * from './request';
7
+ export * from './response';
8
+ export * from './sanitize';
9
+ export * from './sse';
@@ -0,0 +1,26 @@
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
+ __exportStar(require("./common"), exports);
18
+ __exportStar(require("./controller"), exports);
19
+ __exportStar(require("./cors"), exports);
20
+ __exportStar(require("./error"), exports);
21
+ __exportStar(require("./multipart"), exports);
22
+ __exportStar(require("./request"), exports);
23
+ __exportStar(require("./response"), exports);
24
+ __exportStar(require("./sanitize"), exports);
25
+ __exportStar(require("./sse"), exports);
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/core/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,+CAA6B;AAC7B,yCAAuB;AACvB,0CAAwB;AACxB,8CAA4B;AAC5B,4CAA0B;AAC1B,6CAA2B;AAC3B,6CAA2B;AAC3B,wCAAsB"}
@@ -0,0 +1,8 @@
1
+ export interface MultipartFile {
2
+ fieldname: string;
3
+ filename: string;
4
+ contentType: string;
5
+ data: Buffer;
6
+ size: number;
7
+ encoding?: string;
8
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=multipart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multipart.js","sourceRoot":"","sources":["../../../src/types/core/multipart.ts"],"names":[],"mappings":""}
@@ -0,0 +1,65 @@
1
+ import { IncomingHttpHeaders } from 'http';
2
+ export type RequestSource = 'http' | 'lambda' | 'unknown';
3
+ export type EventType = 'apigateway' | 'apigatewayv2' | 'alb' | 'cloudfront' | 's3' | 'sns' | 'sqs' | 'dynamodb' | 'unknown';
4
+ export interface RequestOptions {
5
+ method: string;
6
+ requestUrl: URL;
7
+ url: string;
8
+ path: string;
9
+ headers: Record<string, string | string[]>;
10
+ query: Record<string, string | string[]>;
11
+ body: any;
12
+ params: Record<string, string>;
13
+ cookies: Record<string, string>;
14
+ sourceIp?: string;
15
+ userAgent?: string;
16
+ requestId: string;
17
+ stage?: string;
18
+ timestamp: Date;
19
+ raw?: any;
20
+ context?: any;
21
+ rawBody?: any;
22
+ event?: unknown;
23
+ isBase64Encoded?: boolean;
24
+ source: RequestSource;
25
+ }
26
+ export interface IRequest {
27
+ method: string;
28
+ path: string;
29
+ url: string;
30
+ requestUrl: URL;
31
+ headers: Record<string, string | string[]>;
32
+ query: Record<string, string | string[]>;
33
+ body: any;
34
+ params: Record<string, string>;
35
+ cookies: Record<string, string>;
36
+ sourceIp: string;
37
+ userAgent: string;
38
+ requestId: string;
39
+ stage: string;
40
+ timestamp: Date;
41
+ source: RequestSource;
42
+ raw: any;
43
+ context: any;
44
+ rawBody: any;
45
+ isBase64Encoded: any;
46
+ startTime: number;
47
+ getHeader(name: string): string | string[] | undefined;
48
+ getCookie(name: string): string | undefined;
49
+ getQuery(name: string): string | string[] | undefined;
50
+ getParam(name: string): string | undefined;
51
+ isHttp(): boolean;
52
+ isLambda(): boolean;
53
+ getLambdaEvent(): unknown;
54
+ getLambdaContext(): unknown;
55
+ getHttpRequest(): IncomingHttpHeaders | undefined;
56
+ setState(key: string, value: any): void;
57
+ getState<T = any>(key: string): T | undefined;
58
+ getAllState(): Map<string, any>;
59
+ isSecure(): boolean;
60
+ getClientIp(): string;
61
+ getHost(): string;
62
+ getFullUrl(): string;
63
+ clone(overrides?: Partial<RequestOptions>): IRequest;
64
+ toJSON(): Record<string, any>;
65
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.js","sourceRoot":"","sources":["../../../src/types/core/request.ts"],"names":[],"mappings":""}
@@ -0,0 +1,49 @@
1
+ export type ResponseSource = 'http' | 'lambda' | 'unknown';
2
+ export interface CookieOptions {
3
+ maxAge?: number;
4
+ expires?: Date;
5
+ path?: string;
6
+ domain?: string;
7
+ secure?: boolean;
8
+ httpOnly?: boolean;
9
+ sameSite?: 'strict' | 'lax' | 'none';
10
+ priority?: 'low' | 'medium' | 'high';
11
+ partitioned?: boolean;
12
+ }
13
+ export interface ResponseOptions {
14
+ statusCode?: number;
15
+ headers?: Record<string, string | string[]>;
16
+ body?: any;
17
+ cookies?: string[];
18
+ isBase64Encoded?: boolean;
19
+ encoding?: BufferEncoding;
20
+ }
21
+ export interface IResponse {
22
+ headers: Record<string, string | string[]>;
23
+ data: any;
24
+ cookies: string[];
25
+ isBase64Encoded: boolean;
26
+ source: ResponseSource;
27
+ raw: any;
28
+ headersSent: boolean;
29
+ ok: boolean;
30
+ meta: {
31
+ requestUrl: URL;
32
+ method: string;
33
+ };
34
+ status: number;
35
+ getStatus(): number;
36
+ setHeader(name: string, value: string | string[]): this;
37
+ getHeader(name: string): string | string[] | undefined;
38
+ hasHeader(name: string): boolean;
39
+ removeHeader(name: string): this;
40
+ setHeaders(headers: Record<string, string | string[]>): this;
41
+ setCookie(name: string, value: string, options?: CookieOptions): this;
42
+ clearCookie(name: string, options?: CookieOptions): this;
43
+ getCookies(): string[];
44
+ redirect(url: string, statusCode?: number): this;
45
+ end(data: unknown): this;
46
+ error(data: unknown): this;
47
+ reset(): this;
48
+ toJSON(): Record<string, any>;
49
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=response.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.js","sourceRoot":"","sources":["../../../src/types/core/response.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import * as Joi from 'joi';
2
+ export interface SanitizerConfig {
3
+ schema: Joi.Schema;
4
+ action?: 'validate' | 'sanitize' | 'both';
5
+ options?: Joi.ValidationOptions;
6
+ stripUnknown?: boolean;
7
+ type: 'headers' | 'body' | 'params' | 'query';
8
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=sanitize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitize.js","sourceRoot":"","sources":["../../../src/types/core/sanitize.ts"],"names":[],"mappings":""}
@@ -0,0 +1,37 @@
1
+ import { ServerResponse } from 'http';
2
+ export interface SSEClient {
3
+ id: string;
4
+ response: ServerResponse;
5
+ topics: Set<string>;
6
+ data: Record<string, any>;
7
+ connectedAt: Date;
8
+ }
9
+ export interface SSEMessage {
10
+ event?: string;
11
+ id?: string;
12
+ retry?: number;
13
+ data: any;
14
+ }
15
+ export interface SSEEvent {
16
+ type: 'connection' | 'close';
17
+ client: SSEClient;
18
+ data?: any;
19
+ }
20
+ export interface ISSEServer {
21
+ createConnection(res: ServerResponse): SSEClient;
22
+ sendToClient(clientId: string, message: SSEMessage): boolean;
23
+ broadcast(message: SSEMessage, excludeClientId?: string): void;
24
+ getStats(): {
25
+ clients: number;
26
+ };
27
+ }
28
+ export interface ISSEService {
29
+ initialize(sse: ISSEServer): void;
30
+ sendToClient(clientId: string, message: SSEMessage): boolean;
31
+ broadcast(message: SSEMessage, excludeClientId?: string): void;
32
+ getStats(): {
33
+ clients: number;
34
+ };
35
+ isAvailable(): boolean;
36
+ createConnection(res: ServerResponse): SSEClient;
37
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=sse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sse.js","sourceRoot":"","sources":["../../../src/types/core/sse.ts"],"names":[],"mappings":""}
@@ -0,0 +1,50 @@
1
+ import WebSocket from 'ws';
2
+ export type WebSocketHandlerType = 'connection' | 'message' | 'close' | 'error';
3
+ export interface WebSocketEvent {
4
+ type: WebSocketHandlerType;
5
+ client: WebSocketClient;
6
+ message?: WebSocketMessage;
7
+ data?: any;
8
+ }
9
+ export interface WebSocketClient {
10
+ id: string;
11
+ socket: WebSocket;
12
+ topics: Set<string>;
13
+ data: Record<string, any>;
14
+ connectedAt: Date;
15
+ }
16
+ export interface WebSocketMessage {
17
+ type: string;
18
+ topic?: string;
19
+ data: any;
20
+ clientId?: string;
21
+ }
22
+ export interface WebSocketStats {
23
+ clients: number;
24
+ topics: Array<{
25
+ topic: string;
26
+ subscribers: number;
27
+ }>;
28
+ }
29
+ export interface IWebSocketService {
30
+ sendToClient(clientId: string, message: any): boolean;
31
+ publishToTopic(topic: string, data: any, exclude?: string[]): void;
32
+ broadcast(message: any, excludeClientId?: string): void;
33
+ getStats(): {
34
+ clients: number;
35
+ topics: Array<{
36
+ topic: string;
37
+ subscribers: number;
38
+ }>;
39
+ };
40
+ isAvailable(): boolean;
41
+ }
42
+ export interface IWebSocketServer {
43
+ sendToClient(clientId: string, message: any): boolean;
44
+ publishToTopic(topic: string, data: any, exclude: string[]): void;
45
+ broadcast(message: any, excludeClientId?: string): void;
46
+ getStats(): WebSocketStats;
47
+ subscribeToTopic(client: WebSocketClient, topic: string): void;
48
+ unsubscribeFromTopic(client: WebSocketClient, topic: string): void;
49
+ registerControllers(controllers: any[]): void;
50
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/ws/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ import 'reflect-metadata';
2
+ import { ControllerInstance, ControllerMethods, CORSConfig, InterceptorCB, IRequest, IResponse, MiddlewareCB, SanitizerConfig } from '../../types/core';
3
+ export declare const executeControllerMethod: (controller: ControllerInstance, propertyName: string, request: IRequest, response: IResponse) => Promise<any>;
4
+ export declare const getControllerMethods: (controller: ControllerInstance) => ControllerMethods;
5
+ export declare const getAllMethods: (obj: any) => string[];
6
+ export declare const findRouteInController: (instance: any, path: string, route: string, method: string) => {
7
+ name: string;
8
+ pathParams: Record<string, string>;
9
+ priority: number;
10
+ middlewares: MiddlewareCB[];
11
+ cors?: CORSConfig;
12
+ sanitizers: SanitizerConfig[];
13
+ };
14
+ export declare const NextFunction: (error: any) => void;
15
+ export declare const getResponse: (data: {
16
+ controllerInstance: ControllerInstance;
17
+ name: string;
18
+ interceptors: InterceptorCB[];
19
+ request: IRequest;
20
+ response: IResponse;
21
+ }) => Promise<any>;
22
+ export declare const applyMiddlewaresVsSanitizers: (request: IRequest, response: IResponse, functions: {
23
+ sanitizers: SanitizerConfig[][];
24
+ middlewares: MiddlewareCB[][];
25
+ }) => Promise<void>;