@creator.co/wapi 1.6.0 → 2.0.0-alpha.1

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/.github/workflows/npmpublish.yml +1 -1
  2. package/.github/workflows/prs.yml +1 -1
  3. package/dist/index.js +45 -31
  4. package/dist/index.js.map +1 -1
  5. package/dist/jest.config.js +2 -4
  6. package/dist/jest.config.js.map +1 -1
  7. package/dist/package.json +12 -12
  8. package/dist/src/API/Request.js +53 -59
  9. package/dist/src/API/Request.js.map +1 -1
  10. package/dist/src/API/Response.js +81 -156
  11. package/dist/src/API/Response.js.map +1 -1
  12. package/dist/src/BaseEvent/EventProcessor.js +54 -132
  13. package/dist/src/BaseEvent/EventProcessor.js.map +1 -1
  14. package/dist/src/BaseEvent/Process.js +40 -98
  15. package/dist/src/BaseEvent/Process.js.map +1 -1
  16. package/dist/src/BaseEvent/Transaction.js +122 -310
  17. package/dist/src/BaseEvent/Transaction.js.map +1 -1
  18. package/dist/src/Cache/Redis.js +55 -119
  19. package/dist/src/Cache/Redis.js.map +1 -1
  20. package/dist/src/Cache/types.js +1 -2
  21. package/dist/src/Config/Configuration.js +46 -86
  22. package/dist/src/Config/Configuration.js.map +1 -1
  23. package/dist/src/Config/EnvironmentVar.js +57 -119
  24. package/dist/src/Config/EnvironmentVar.js.map +1 -1
  25. package/dist/src/Crypto/Crypto.js +35 -82
  26. package/dist/src/Crypto/Crypto.js.map +1 -1
  27. package/dist/src/Crypto/JWT.js +12 -27
  28. package/dist/src/Crypto/JWT.js.map +1 -1
  29. package/dist/src/Database/Database.js +3 -8
  30. package/dist/src/Database/Database.js.map +1 -1
  31. package/dist/src/Database/DatabaseManager.js +23 -28
  32. package/dist/src/Database/DatabaseManager.js.map +1 -1
  33. package/dist/src/Database/DatabaseTransaction.js +50 -166
  34. package/dist/src/Database/DatabaseTransaction.js.map +1 -1
  35. package/dist/src/Database/index.js +11 -15
  36. package/dist/src/Database/index.js.map +1 -1
  37. package/dist/src/Database/integrations/knex/KnexDatabase.js +22 -76
  38. package/dist/src/Database/integrations/knex/KnexDatabase.js.map +1 -1
  39. package/dist/src/Database/integrations/knex/KnexTransaction.js +19 -85
  40. package/dist/src/Database/integrations/knex/KnexTransaction.js.map +1 -1
  41. package/dist/src/Database/integrations/kysely/KyselyDatabase.js +37 -88
  42. package/dist/src/Database/integrations/kysely/KyselyDatabase.js.map +1 -1
  43. package/dist/src/Database/integrations/kysely/KyselyTransaction.js +46 -114
  44. package/dist/src/Database/integrations/kysely/KyselyTransaction.js.map +1 -1
  45. package/dist/src/Database/integrations/pgsql/PostgresDatabase.js +20 -71
  46. package/dist/src/Database/integrations/pgsql/PostgresDatabase.js.map +1 -1
  47. package/dist/src/Database/integrations/pgsql/PostgresTransaction.js +19 -85
  48. package/dist/src/Database/integrations/pgsql/PostgresTransaction.js.map +1 -1
  49. package/dist/src/Database/types.js +1 -2
  50. package/dist/src/Globals.js +93 -98
  51. package/dist/src/Globals.js.map +1 -1
  52. package/dist/src/Logger/Logger.js +88 -222
  53. package/dist/src/Logger/Logger.js.map +1 -1
  54. package/dist/src/Mailer/Mailer.js +83 -204
  55. package/dist/src/Mailer/Mailer.js.map +1 -1
  56. package/dist/src/Publisher/Publisher.js +43 -107
  57. package/dist/src/Publisher/Publisher.js.map +1 -1
  58. package/dist/src/Server/RouteResolver.js +22 -49
  59. package/dist/src/Server/RouteResolver.js.map +1 -1
  60. package/dist/src/Server/Router.js +12 -16
  61. package/dist/src/Server/Router.js.map +1 -1
  62. package/dist/src/Server/lib/ContainerServer.js +21 -83
  63. package/dist/src/Server/lib/ContainerServer.js.map +1 -1
  64. package/dist/src/Server/lib/Server.js +50 -99
  65. package/dist/src/Server/lib/Server.js.map +1 -1
  66. package/dist/src/Server/lib/container/GenericHandler.js +32 -107
  67. package/dist/src/Server/lib/container/GenericHandler.js.map +1 -1
  68. package/dist/src/Server/lib/container/GenericHandlerEvent.js +37 -81
  69. package/dist/src/Server/lib/container/GenericHandlerEvent.js.map +1 -1
  70. package/dist/src/Server/lib/container/HealthHandler.js +3 -35
  71. package/dist/src/Server/lib/container/HealthHandler.js.map +1 -1
  72. package/dist/src/Server/lib/container/Proxy.js +64 -127
  73. package/dist/src/Server/lib/container/Proxy.js.map +1 -1
  74. package/dist/src/Server/lib/container/Utils.js +12 -55
  75. package/dist/src/Server/lib/container/Utils.js.map +1 -1
  76. package/dist/src/Util/AsyncSingleton.js +40 -164
  77. package/dist/src/Util/AsyncSingleton.js.map +1 -1
  78. package/dist/src/Util/Utils.js +18 -24
  79. package/dist/src/Util/Utils.js.map +1 -1
  80. package/dist/src/Validation/Validator.js +10 -16
  81. package/dist/src/Validation/Validator.js.map +1 -1
  82. package/package.json +12 -12
  83. package/src/Logger/Logger.ts +2 -2
  84. package/tests/Logger/Logger.test.ts +6 -4
  85. package/tsconfig.json +3 -1
@@ -8,4 +8,4 @@ jobs:
8
8
  uses: Creator-co/tool-github-workflows/.github/workflows/npm-publish.yml@main
9
9
  secrets: inherit
10
10
  with:
11
- NODE_VERSION: "16.x"
11
+ NODE_VERSION: "20.x"
@@ -10,4 +10,4 @@ jobs:
10
10
  uses: Creator-co/tool-github-workflows/.github/workflows/prs-check.yml@main
11
11
  secrets: inherit
12
12
  with:
13
- NODE_VERSION: "16.x"
13
+ NODE_VERSION: "20.x"
package/dist/index.js CHANGED
@@ -1,32 +1,46 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Database = exports.HttpMethod = exports.AsyncSingleton = exports.Utils = exports.Response = exports.Redis = exports.Configuration = exports.JWT = exports.Crypto = exports.Mailer = exports.Router = exports.EventProcessor = exports.Process = exports.Transaction = void 0;
4
- var Request_1 = require("./src/API/Request");
5
- Object.defineProperty(exports, "HttpMethod", { enumerable: true, get: function () { return Request_1.HttpMethod; } });
6
- var Response_1 = require("./src/API/Response");
7
- exports.Response = Response_1.default;
8
- var EventProcessor_1 = require("./src/BaseEvent/EventProcessor");
9
- exports.EventProcessor = EventProcessor_1.default;
10
- var Process_1 = require("./src/BaseEvent/Process");
11
- exports.Process = Process_1.default;
12
- var Transaction_1 = require("./src/BaseEvent/Transaction");
13
- exports.Transaction = Transaction_1.default;
14
- var Redis_1 = require("./src/Cache/Redis");
15
- exports.Redis = Redis_1.default;
16
- var Configuration_1 = require("./src/Config/Configuration");
17
- exports.Configuration = Configuration_1.default;
18
- var Crypto_1 = require("./src/Crypto/Crypto");
19
- exports.Crypto = Crypto_1.default;
20
- var JWT_1 = require("./src/Crypto/JWT");
21
- exports.JWT = JWT_1.default;
22
- var Database = require("./src/Database");
23
- exports.Database = Database;
24
- var Mailer_1 = require("./src/Mailer/Mailer");
25
- exports.Mailer = Mailer_1.default;
26
- var Router_1 = require("./src/Server/Router");
27
- exports.Router = Router_1.default;
28
- var AsyncSingleton_1 = require("./src/Util/AsyncSingleton");
29
- exports.AsyncSingleton = AsyncSingleton_1.default;
30
- var Utils_1 = require("./src/Util/Utils");
31
- exports.Utils = Utils_1.default;
1
+ import { HttpMethod } from './src/API/Request';
2
+ import Response from './src/API/Response';
3
+ import EventProcessor from './src/BaseEvent/EventProcessor';
4
+ import Process from './src/BaseEvent/Process';
5
+ import Transaction from './src/BaseEvent/Transaction';
6
+ import Redis from './src/Cache/Redis';
7
+ import Configuration from './src/Config/Configuration';
8
+ import Crypto from './src/Crypto/Crypto';
9
+ import JWT from './src/Crypto/JWT';
10
+ import * as Database from './src/Database';
11
+ import Mailer from './src/Mailer/Mailer';
12
+ import Router from './src/Server/Router';
13
+ import AsyncSingleton from './src/Util/AsyncSingleton';
14
+ import Utils from './src/Util/Utils';
15
+ /**
16
+ * This module exports various classes and utilities for handling transactions, processes, events, routing,
17
+ * mailing, cryptography, JWT, configuration, Redis, responses, utilities, routes, response error types,
18
+ * HTTP methods, and databases.
19
+ * @exports {
20
+ * Transaction,
21
+ * Process,
22
+ * EventProcessor,
23
+ * Router,
24
+ * Mailer,
25
+ * Crypto,
26
+ * JWT,
27
+ * Configuration,
28
+ * Redis,
29
+ * Response,
30
+ * Utils,
31
+ * Route,
32
+ * ResponseErrorType,
33
+ * HttpMethod,
34
+ * Database,
35
+ * }
36
+ */
37
+ export {
38
+ // Base Events
39
+ Transaction, Process, EventProcessor, Router,
40
+ // Externally initialized clients
41
+ Mailer, Crypto, JWT, Configuration, Redis,
42
+ // API
43
+ Response,
44
+ // Helpers
45
+ Utils, AsyncSingleton, HttpMethod, Database, };
32
46
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,6CAA8C;AAyD5C,2FAzDO,oBAAU,OAyDP;AAxDZ,+CAAgE;AAiD9D,mBAjDK,kBAAQ,CAiDL;AAhDV,iEAA2D;AAuCzD,yBAvCK,wBAAc,CAuCL;AAtChB,mDAA6C;AAqC3C,kBArCK,iBAAO,CAqCL;AApCT,2DAAqD;AAmCnD,sBAnCK,qBAAW,CAmCL;AAlCb,2CAAqC;AA2CnC,gBA3CK,eAAK,CA2CL;AA1CP,4DAAsD;AAyCpD,wBAzCK,uBAAa,CAyCL;AAxCf,8CAAwC;AAsCtC,iBAtCK,gBAAM,CAsCL;AArCR,wCAAkC;AAsChC,cAtCK,aAAG,CAsCL;AArCL,yCAA0C;AAiDxC,4BAAQ;AAhDV,8CAAwC;AAkCtC,iBAlCK,gBAAM,CAkCL;AAjCR,8CAAmD;AA+BjD,iBA/BK,gBAAM,CA+BL;AA9BR,4DAAsD;AAyCpD,yBAzCK,wBAAc,CAyCL;AAxChB,0CAAoC;AAuClC,gBAvCK,eAAK,CAuCL"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,QAA+B,MAAM,oBAAoB,CAAA;AAChE,OAAO,cAAc,MAAM,gCAAgC,CAAA;AAC3D,OAAO,OAAO,MAAM,yBAAyB,CAAA;AAC7C,OAAO,WAAW,MAAM,6BAA6B,CAAA;AACrD,OAAO,KAAK,MAAM,mBAAmB,CAAA;AACrC,OAAO,aAAa,MAAM,4BAA4B,CAAA;AACtD,OAAO,MAAM,MAAM,qBAAqB,CAAA;AACxC,OAAO,GAAG,MAAM,kBAAkB,CAAA;AAClC,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAC1C,OAAO,MAAM,MAAM,qBAAqB,CAAA;AACxC,OAAO,MAAiB,MAAM,qBAAqB,CAAA;AACnD,OAAO,cAAc,MAAM,2BAA2B,CAAA;AACtD,OAAO,KAAK,MAAM,kBAAkB,CAAA;AAEpC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO;AACL,cAAc;AACd,WAAW,EACX,OAAO,EACP,cAAc,EACd,MAAM;AACN,iCAAiC;AACjC,MAAM,EACN,MAAM,EACN,GAAG,EACH,aAAa,EACb,KAAK;AACL,MAAM;AACN,QAAQ;AACR,UAAU;AACV,KAAK,EACL,cAAc,EAId,UAAU,EACV,QAAQ,GACT,CAAA"}
@@ -1,7 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
1
  /* eslint-env node */
4
- var config = {
2
+ const config = {
5
3
  preset: 'ts-jest',
6
4
  testEnvironment: 'node',
7
5
  reporters: [
@@ -30,5 +28,5 @@ var config = {
30
28
  },
31
29
  },
32
30
  };
33
- exports.default = config;
31
+ export default config;
34
32
  //# sourceMappingURL=jest.config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"jest.config.js","sourceRoot":"","sources":["../jest.config.ts"],"names":[],"mappings":";;AACA,qBAAqB;AACrB,IAAM,MAAM,GAA0B;IACpC,MAAM,EAAE,SAAS;IACjB,eAAe,EAAE,MAAM;IACvB,SAAS,EAAE;QACT,SAAS;QACT;YACE,YAAY;YACZ;gBACE,eAAe,EAAE,UAAU;gBAC3B,UAAU,EAAE,gBAAgB;gB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;YACT,UAAU,EAAE,EAAE;SACf;KACF;CACF,CAAA;AACD,eAAe,MAAM,CAAA"}
package/dist/package.json CHANGED
@@ -1,27 +1,27 @@
1
1
  {
2
2
  "name": "@creator.co/wapi",
3
- "version": "1.6.0",
3
+ "version": "2.0.0-alpha.1",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
- "type": "commonjs",
7
+ "type": "module",
8
8
  "scripts": {
9
9
  "build": "tsc --build",
10
10
  "clean": "tsc --build --clean",
11
11
  "lint-fix": "eslint . --ext .ts --fix",
12
12
  "lint": "eslint . --ext .ts",
13
- "test": "jest --coverage --silent --runInBand && cat coverage/coverage.txt",
13
+ "test": "jest --coverage --silent --runInBand --logHeapUsage && cat coverage/coverage.txt",
14
14
  "test-dev": "jest --coverage --runInBand && cat coverage/coverage.txt"
15
15
  },
16
16
  "author": "",
17
17
  "license": "ISC",
18
18
  "dependencies": {
19
- "@aws-sdk/client-kms": "^3.509.0",
20
- "@aws-sdk/client-secrets-manager": "^3.509.0",
21
- "@aws-sdk/client-ses": "^3.509.0",
22
- "@aws-sdk/client-sns": "^3.509.0",
23
- "@aws-sdk/client-ssm": "^3.509.0",
24
- "@aws-sdk/credential-provider-node": "^3.509.0",
19
+ "@aws-sdk/client-kms": "^3.556.0",
20
+ "@aws-sdk/client-secrets-manager": "3.556",
21
+ "@aws-sdk/client-ses": "3.556",
22
+ "@aws-sdk/client-sns": "3.556",
23
+ "@aws-sdk/client-ssm": "3.556",
24
+ "@aws-sdk/credential-provider-node": "3.556",
25
25
  "@types/email-templates": "^10.0.1",
26
26
  "@types/nodemailer": "^6.4.10",
27
27
  "@types/object-hash": "^3.0.4",
@@ -39,12 +39,12 @@
39
39
  "node-cache": "^5.1.2",
40
40
  "object-hash": "^3.0.0",
41
41
  "parse-duration": "^1.1.0",
42
- "path-to-regexp": "^6.2.1",
42
+ "path-to-regexp": "^6.2.2",
43
43
  "pg": "^8.11.3",
44
44
  "redis": "^4.6.13",
45
45
  "sha1": "^1.1.1",
46
46
  "stack-trace": "0.0.10",
47
- "zod": "^3.22.4"
47
+ "zod": "^3.23.0"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@jest/globals": "^29.7.0",
@@ -62,7 +62,7 @@
62
62
  "@typescript-eslint/parser": "^6.21.0",
63
63
  "aws-lambda": "^1.0.7",
64
64
  "aws-sdk-client-mock": "^3.0.0",
65
- "chai": "^4.3.10",
65
+ "chai": "^4.4.1",
66
66
  "eslint": "^8.48.0",
67
67
  "eslint-config-prettier": "^9.0.0",
68
68
  "eslint-plugin-import": "^2.28.1",
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HttpMethod = void 0;
4
- var Utils_1 = require("../Util/Utils");
1
+ import Utils from '../Util/Utils';
5
2
  /**
6
3
  * Represents a request object with generic types for input, query parameters, and path parameters.
7
4
  * @class Request
@@ -9,7 +6,7 @@ var Utils_1 = require("../Util/Utils");
9
6
  * @template PathParamsType - The type of the path parameters for the request.
10
7
  * @template QueryParamsType - The type of the query parameters for the request.
11
8
  */
12
- var Request = /** @class */ (function () {
9
+ export default class Request {
13
10
  /**
14
11
  * Constructs a new instance of the class.
15
12
  * @param {APIGatewayEvent} requestEvent - The API Gateway event object.
@@ -17,7 +14,7 @@ var Request = /** @class */ (function () {
17
14
  * @param {Logger} logger - The logger object.
18
15
  * @returns None
19
16
  */
20
- function Request(requestEvent, context, logger) {
17
+ constructor(requestEvent, context, logger) {
21
18
  this.requestEvent = requestEvent;
22
19
  this.context = context;
23
20
  logger.debug('Request info:', requestEvent);
@@ -28,59 +25,59 @@ var Request = /** @class */ (function () {
28
25
  * @param {keyof QueryParamsType} paramName - The name of the query parameter to check.
29
26
  * @returns {boolean} - True if the query parameter exists and has a valid value, false otherwise.
30
27
  */
31
- Request.prototype.containsQueryParam = function (paramName) {
32
- var val = this.getQueryParam(paramName);
33
- return !!val && (Utils_1.default.isValidString(val) || Utils_1.default.isValidNumber(val));
34
- };
28
+ containsQueryParam(paramName) {
29
+ const val = this.getQueryParam(paramName);
30
+ return !!val && (Utils.isValidString(val) || Utils.isValidNumber(val));
31
+ }
35
32
  /**
36
33
  * Retrieves the value of a query parameter from the URL.
37
34
  * @param {keyof QueryParamsType} paramName - The name of the query parameter to retrieve.
38
35
  * @returns {string | null} The value of the query parameter, or null if it does not exist.
39
36
  */
40
- Request.prototype.getQueryParam = function (paramName) {
41
- return Utils_1.default.caseInsensitiveObjectForKey(this.requestEvent.queryStringParameters, String(paramName));
42
- };
37
+ getQueryParam(paramName) {
38
+ return Utils.caseInsensitiveObjectForKey(this.requestEvent.queryStringParameters, String(paramName));
39
+ }
43
40
  /**
44
41
  * Retrieves the value of the specified header from the request event headers.
45
42
  * @param {string} headerName - The name of the header to retrieve.
46
43
  * @returns {string | null} - The value of the header, or null if the header is not found.
47
44
  */
48
- Request.prototype.getHeader = function (headerName) {
49
- return Utils_1.default.caseInsensitiveObjectForKey(this.requestEvent.headers, headerName);
50
- };
45
+ getHeader(headerName) {
46
+ return Utils.caseInsensitiveObjectForKey(this.requestEvent.headers, headerName);
47
+ }
51
48
  /**
52
49
  * Retrieves the value of a context parameter from the request context object.
53
50
  * @param {string} cxtParam - The name of the context parameter to retrieve.
54
51
  * @returns The value of the context parameter, or null if it does not exist.
55
52
  */
56
- Request.prototype.getContextParam = function (cxtParam) {
57
- return Utils_1.default.caseInsensitiveObjectForKey(this.requestEvent.requestContext, cxtParam);
58
- };
53
+ getContextParam(cxtParam) {
54
+ return Utils.caseInsensitiveObjectForKey(this.requestEvent.requestContext, cxtParam);
55
+ }
59
56
  /**
60
57
  * Checks if the given parameter name exists in the PathParamsType object.
61
58
  * @param {keyof PathParamsType} paramName - The name of the parameter to check.
62
59
  * @returns {boolean} - True if the parameter exists, false otherwise.
63
60
  */
64
- Request.prototype.containsPathParam = function (paramName) {
65
- var val = this.getPathParam(paramName);
66
- return !!val && (Utils_1.default.isValidString(val) || Utils_1.default.isValidNumber(val));
67
- };
61
+ containsPathParam(paramName) {
62
+ const val = this.getPathParam(paramName);
63
+ return !!val && (Utils.isValidString(val) || Utils.isValidNumber(val));
64
+ }
68
65
  /**
69
66
  * Retrieves the value of a specific path parameter from the URL.
70
67
  * @param {keyof PathParamsType} paramName - The name of the path parameter to retrieve.
71
68
  * @returns {string} The value of the path parameter, or null if it does not exist.
72
69
  */
73
- Request.prototype.getPathParam = function (paramName) {
74
- return Utils_1.default.caseInsensitiveObjectForKey(this.requestEvent.pathParameters, String(paramName));
75
- };
70
+ getPathParam(paramName) {
71
+ return Utils.caseInsensitiveObjectForKey(this.requestEvent.pathParameters, String(paramName));
72
+ }
76
73
  /**
77
74
  * Retrieves the body of the request event and parses it if it is a string.
78
75
  * @returns {InputType} The parsed body of the request event.
79
76
  */
80
- Request.prototype.getBody = function (raw) {
81
- var body = this.requestEvent.body;
77
+ getBody(raw) {
78
+ const body = this.requestEvent.body;
82
79
  if (raw)
83
- return Utils_1.default.isHybridlessContainer() ? this.requestEvent['rawBody'] : body;
80
+ return Utils.isHybridlessContainer() ? this.requestEvent['rawBody'] : body;
84
81
  if (typeof body === 'string' || body instanceof String) {
85
82
  try {
86
83
  return JSON.parse(body);
@@ -90,92 +87,89 @@ var Request = /** @class */ (function () {
90
87
  }
91
88
  }
92
89
  return body;
93
- };
90
+ }
94
91
  /**
95
92
  * Retrieves the path from the request event.
96
93
  * @returns {string} The path of the request event.
97
94
  */
98
- Request.prototype.getPath = function () {
95
+ getPath() {
99
96
  return this.requestEvent.path;
100
- };
97
+ }
101
98
  /**
102
99
  * Retrieves the HTTP method of the current request.
103
100
  * @returns {string} The HTTP method of the request.
104
101
  */
105
- Request.prototype.getMethod = function () {
102
+ getMethod() {
106
103
  if (this.requestEvent.httpMethod) {
107
- var httpMethod = this.requestEvent.httpMethod.toUpperCase();
104
+ const httpMethod = this.requestEvent.httpMethod.toUpperCase();
108
105
  if (httpMethod in HttpMethod) {
109
106
  return HttpMethod[httpMethod];
110
107
  }
111
108
  }
112
- throw new Error("Invalid HTTP method: ".concat(this.requestEvent.httpMethod));
113
- };
109
+ throw new Error(`Invalid HTTP method: ${this.requestEvent.httpMethod}`);
110
+ }
114
111
  /**
115
112
  * Retrieves the path parameters from the request event.
116
113
  * @returns {PathParamsType | null} - The path parameters object, or null if not found.
117
114
  */
118
- Request.prototype.getPathParams = function () {
115
+ getPathParams() {
119
116
  // type conversion guaranteed by validation
120
117
  return this.requestEvent.pathParameters;
121
- };
118
+ }
122
119
  /**
123
120
  * Retrieves the query parameters from the request event.
124
121
  * @returns {QueryParamsType | null} - The query parameters object, or null if not found.
125
122
  */
126
- Request.prototype.getQueryParams = function () {
123
+ getQueryParams() {
127
124
  // type conversion guaranteed by validation
128
125
  return this.requestEvent.queryStringParameters;
129
- };
126
+ }
130
127
  /**
131
128
  * Retrieves the value of the 'Authorization' header from the request.
132
129
  * @returns The value of the 'Authorization' header, or null if it is not present.
133
130
  */
134
- Request.prototype.getAuthorizationHeader = function () {
131
+ getAuthorizationHeader() {
135
132
  return this.getHeader('Authorization');
136
- };
133
+ }
137
134
  /**
138
135
  * Retrieves the request ID associated with the current execution context.
139
136
  * @returns {string} The request ID.
140
137
  */
141
- Request.prototype.getRequestID = function () {
138
+ getRequestID() {
142
139
  if (this.context.awsRequestId)
143
140
  return this.context.awsRequestId;
144
141
  return this.requestEvent.requestContext ? this.requestEvent.requestContext.requestId : 'unknown';
145
- };
142
+ }
146
143
  /**
147
144
  * Retrieves the origin IP address of the request.
148
145
  * @returns {string} The origin IP address. If the IP address is not available, it returns 'unknown'.
149
146
  */
150
- Request.prototype.getOriginIP = function () {
147
+ getOriginIP() {
151
148
  var _a;
152
- var origin = (_a = this.getContextParam('identity')) === null || _a === void 0 ? void 0 : _a.sourceIp;
153
- var hOrigin = this.getHeader('X-Forwarded-For');
149
+ const origin = (_a = this.getContextParam('identity')) === null || _a === void 0 ? void 0 : _a.sourceIp;
150
+ const hOrigin = this.getHeader('X-Forwarded-For');
154
151
  return origin ? origin : hOrigin ? hOrigin : 'unknown';
155
- };
152
+ }
156
153
  /**
157
154
  * Sets the fixed path parameters in the request event object.
158
155
  * @param {any[]} keys - An array of keys representing the path parameter names.
159
156
  * @param {any[]} result - An array of values representing the path parameter values.
160
157
  * @returns None
161
158
  */
162
- Request.prototype.setFixedPathParams = function (keys, result) {
163
- var _this = this;
159
+ setFixedPathParams(keys, result) {
164
160
  this.requestEvent.pathParameters = {};
165
- keys.forEach(function (key, index) {
161
+ keys.forEach((key, index) => {
166
162
  var _a;
167
- if ((_a = _this.requestEvent) === null || _a === void 0 ? void 0 : _a.pathParameters) {
168
- _this.requestEvent.pathParameters[key.name] = result[index + 1];
163
+ if ((_a = this.requestEvent) === null || _a === void 0 ? void 0 : _a.pathParameters) {
164
+ this.requestEvent.pathParameters[key.name] = result[index + 1];
169
165
  }
170
166
  });
171
- };
172
- return Request;
173
- }());
174
- exports.default = Request;
167
+ }
168
+ }
175
169
  /**
176
170
  * Enum representing the HTTP methods.
177
171
  */
178
- var HttpMethod;
172
+ export var HttpMethod;
179
173
  (function (HttpMethod) {
180
174
  HttpMethod["GET"] = "GET";
181
175
  HttpMethod["HEAD"] = "HEAD";
@@ -186,5 +180,5 @@ var HttpMethod;
186
180
  HttpMethod["OPTIONS"] = "OPTIONS";
187
181
  HttpMethod["TRACE"] = "TRACE";
188
182
  HttpMethod["PATCH"] = "PATCH";
189
- })(HttpMethod || (exports.HttpMethod = HttpMethod = {}));
183
+ })(HttpMethod || (HttpMethod = {}));
190
184
  //# sourceMappingURL=Request.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Request.js","sourceRoot":"","sources":["../../../src/API/Request.ts"],"names":[],"mappings":";;;AAGA,uCAAiC;AAEjC;;;;;;GAMG;AACH;IAWE;;;;;;OAMG;IACH,iBAAY,YAA6B,EAAE,OAAgB,EAAE,MAAc;QACzE,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAA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