@creator.co/wapi 1.2.5 → 1.2.6

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 (115) hide show
  1. package/README.md +216 -5
  2. package/dist/index.d.ts +15 -0
  3. package/dist/index.js.map +1 -1
  4. package/dist/package.json +6 -1
  5. package/dist/src/API/Request.d.ts +45 -82
  6. package/dist/src/API/Request.js +49 -77
  7. package/dist/src/API/Request.js.map +1 -1
  8. package/dist/src/API/Response.d.ts +94 -163
  9. package/dist/src/API/Response.js +101 -161
  10. package/dist/src/API/Response.js.map +1 -1
  11. package/dist/src/API/Utils.d.ts +21 -42
  12. package/dist/src/API/Utils.js +22 -43
  13. package/dist/src/API/Utils.js.map +1 -1
  14. package/dist/src/BaseEvent/EventProcessor.d.ts +32 -55
  15. package/dist/src/BaseEvent/EventProcessor.js +30 -38
  16. package/dist/src/BaseEvent/EventProcessor.js.map +1 -1
  17. package/dist/src/BaseEvent/Process.d.ts +20 -43
  18. package/dist/src/BaseEvent/Process.js +16 -27
  19. package/dist/src/BaseEvent/Process.js.map +1 -1
  20. package/dist/src/BaseEvent/Transaction.d.ts +94 -2
  21. package/dist/src/BaseEvent/Transaction.js +49 -4
  22. package/dist/src/BaseEvent/Transaction.js.map +1 -1
  23. package/dist/src/Config/Configuration.d.ts +48 -66
  24. package/dist/src/Config/Configuration.js +25 -42
  25. package/dist/src/Config/Configuration.js.map +1 -1
  26. package/dist/src/Config/EnvironmentVar.d.ts +30 -57
  27. package/dist/src/Config/EnvironmentVar.js +28 -41
  28. package/dist/src/Config/EnvironmentVar.js.map +1 -1
  29. package/dist/src/Crypto/Crypto.d.ts +17 -35
  30. package/dist/src/Crypto/Crypto.js +12 -21
  31. package/dist/src/Crypto/Crypto.js.map +1 -1
  32. package/dist/src/Crypto/JWT.d.ts +21 -32
  33. package/dist/src/Crypto/JWT.js +14 -22
  34. package/dist/src/Crypto/JWT.js.map +1 -1
  35. package/dist/src/Globals.d.ts +26 -94
  36. package/dist/src/Globals.js +26 -95
  37. package/dist/src/Globals.js.map +1 -1
  38. package/dist/src/Logger/Logger.d.ts +82 -105
  39. package/dist/src/Logger/Logger.js +111 -136
  40. package/dist/src/Logger/Logger.js.map +1 -1
  41. package/dist/src/Mailer/Mailer.d.ts +39 -75
  42. package/dist/src/Mailer/Mailer.js +36 -65
  43. package/dist/src/Mailer/Mailer.js.map +1 -1
  44. package/dist/src/Publisher/Publisher.d.ts +17 -25
  45. package/dist/src/Publisher/Publisher.js +21 -32
  46. package/dist/src/Publisher/Publisher.js.map +1 -1
  47. package/dist/src/Server/RouteResolver.d.ts +14 -22
  48. package/dist/src/Server/RouteResolver.js +21 -34
  49. package/dist/src/Server/RouteResolver.js.map +1 -1
  50. package/dist/src/Server/Router.d.ts +72 -51
  51. package/dist/src/Server/Router.js +8 -17
  52. package/dist/src/Server/Router.js.map +1 -1
  53. package/dist/src/Server/lib/ContainerServer.d.ts +15 -31
  54. package/dist/src/Server/lib/ContainerServer.js +13 -28
  55. package/dist/src/Server/lib/ContainerServer.js.map +1 -1
  56. package/dist/src/Server/lib/Server.d.ts +17 -32
  57. package/dist/src/Server/lib/Server.js +18 -28
  58. package/dist/src/Server/lib/Server.js.map +1 -1
  59. package/dist/src/Server/lib/container/GenericHandler.d.ts +5 -0
  60. package/dist/src/Server/lib/container/GenericHandler.js +16 -3
  61. package/dist/src/Server/lib/container/GenericHandler.js.map +1 -1
  62. package/dist/src/Server/lib/container/GenericHandlerEvent.d.ts +22 -37
  63. package/dist/src/Server/lib/container/GenericHandlerEvent.js +29 -41
  64. package/dist/src/Server/lib/container/GenericHandlerEvent.js.map +1 -1
  65. package/dist/src/Server/lib/container/HealthHandler.d.ts +6 -0
  66. package/dist/src/Server/lib/container/HealthHandler.js +6 -0
  67. package/dist/src/Server/lib/container/HealthHandler.js.map +1 -1
  68. package/dist/src/Server/lib/container/Proxy.d.ts +24 -52
  69. package/dist/src/Server/lib/container/Proxy.js +49 -50
  70. package/dist/src/Server/lib/container/Proxy.js.map +1 -1
  71. package/dist/src/Server/lib/container/Utils.d.ts +6 -10
  72. package/dist/src/Server/lib/container/Utils.js +6 -10
  73. package/dist/src/Server/lib/container/Utils.js.map +1 -1
  74. package/dist/src/Validation/Validator.d.ts +9 -13
  75. package/dist/src/Validation/Validator.js +8 -12
  76. package/dist/src/Validation/Validator.js.map +1 -1
  77. package/index.ts +15 -0
  78. package/package.json +6 -1
  79. package/src/API/Request.ts +66 -84
  80. package/src/API/Response.ts +144 -203
  81. package/src/API/Utils.ts +28 -44
  82. package/src/BaseEvent/EventProcessor.ts +52 -77
  83. package/src/BaseEvent/Process.ts +27 -52
  84. package/src/BaseEvent/Transaction.ts +100 -10
  85. package/src/Config/Configuration.ts +59 -76
  86. package/src/Config/EnvironmentVar.ts +39 -62
  87. package/src/Crypto/Crypto.ts +20 -36
  88. package/src/Crypto/JWT.ts +31 -35
  89. package/src/Globals.ts +28 -96
  90. package/src/Logger/Logger.ts +141 -160
  91. package/src/Mailer/Mailer.ts +43 -76
  92. package/src/Publisher/Publisher.ts +31 -40
  93. package/src/Server/RouteResolver.ts +31 -52
  94. package/src/Server/Router.ts +75 -54
  95. package/src/Server/lib/ContainerServer.ts +20 -32
  96. package/src/Server/lib/Server.ts +19 -34
  97. package/src/Server/lib/container/GenericHandler.ts +17 -3
  98. package/src/Server/lib/container/GenericHandlerEvent.ts +44 -54
  99. package/src/Server/lib/container/HealthHandler.ts +6 -0
  100. package/src/Server/lib/container/Proxy.ts +37 -57
  101. package/src/Server/lib/container/Utils.ts +7 -10
  102. package/src/Validation/Validator.ts +11 -13
  103. package/tests/API/Response.test.ts +55 -56
  104. package/tests/BaseEvent/EventProcessor.test.ts +49 -50
  105. package/tests/BaseEvent/Process.test.ts +2 -2
  106. package/tests/BaseEvent/Transaction.test.ts +48 -49
  107. package/tests/Config/Config.test.ts +27 -27
  108. package/tests/Config/EnvironmentVar.test.ts +54 -18
  109. package/tests/Publisher/Publisher.test.ts +3 -3
  110. package/tests/Server/lib/ContainerServer.test.ts +21 -22
  111. package/tests/Server/lib/container/GenericHandler.test.ts +31 -32
  112. package/tests/Server/lib/container/GenericHandlerEvent.test.ts +2 -2
  113. package/tests/Server/lib/container/HealthHandler.test.ts +6 -7
  114. package/tests/Server/lib/container/Proxy.test.ts +37 -35
  115. package/tsconfig.json +1 -1
@@ -1,21 +1,17 @@
1
1
  import { z } from 'zod';
2
2
  import Response, { ResponseErrorType } from '../API/Response';
3
3
  /**
4
- * Description placeholder
5
- *
6
- * @export
7
- * @class Validator
8
- * @typedef {Validator}
4
+ * Validates the given data against the provided schema.
5
+ * @param {any} data - The data to be validated.
6
+ * @param {z.ZodObject<any>} schema - The schema to validate against.
7
+ * @returns {boolean | Response<ResponseErrorType>} - Returns true if the data is valid, otherwise returns a response object with an error message.
9
8
  */
10
9
  export default class Validator {
11
10
  /**
12
- * Description placeholder
13
- *
14
- * @public
15
- * @static
16
- * @param {*} data
17
- * @param {z.ZodObject<any>} schema
18
- * @returns {(boolean | Response<ResponseErrorType>)}
11
+ * Validates the given data against the provided schema.
12
+ * @param {any} data - The data to be validated.
13
+ * @param {z.ZodObject<any> | z.ZodUnion<any>} schema - The schema to validate against.
14
+ * @returns {boolean | Response<ResponseErrorType>} - Returns either true if the data is valid or a Response object with an error message if validation fails.
19
15
  */
20
- static validateSchema(data: any, schema: z.ZodObject<any>): boolean | Response<ResponseErrorType>;
16
+ static validateSchema(data: any, schema: z.ZodObject<any> | z.ZodUnion<any>): boolean | Response<ResponseErrorType>;
21
17
  }
@@ -4,23 +4,19 @@ var zod_1 = require("zod");
4
4
  var Response_1 = require("../API/Response");
5
5
  var Globals_1 = require("../Globals");
6
6
  /**
7
- * Description placeholder
8
- *
9
- * @export
10
- * @class Validator
11
- * @typedef {Validator}
7
+ * Validates the given data against the provided schema.
8
+ * @param {any} data - The data to be validated.
9
+ * @param {z.ZodObject<any>} schema - The schema to validate against.
10
+ * @returns {boolean | Response<ResponseErrorType>} - Returns true if the data is valid, otherwise returns a response object with an error message.
12
11
  */
13
12
  var Validator = /** @class */ (function () {
14
13
  function Validator() {
15
14
  }
16
15
  /**
17
- * Description placeholder
18
- *
19
- * @public
20
- * @static
21
- * @param {*} data
22
- * @param {z.ZodObject<any>} schema
23
- * @returns {(boolean | Response<ResponseErrorType>)}
16
+ * Validates the given data against the provided schema.
17
+ * @param {any} data - The data to be validated.
18
+ * @param {z.ZodObject<any> | z.ZodUnion<any>} schema - The schema to validate against.
19
+ * @returns {boolean | Response<ResponseErrorType>} - Returns either true if the data is valid or a Response object with an error message if validation fails.
24
20
  */
25
21
  Validator.validateSchema = function (data, schema) {
26
22
  var error, validatedInput;
@@ -1 +1 @@
1
- {"version":3,"file":"Validator.js","sourceRoot":"","sources":["../../../src/Validation/Validator.ts"],"names":[],"mappings":";;AAAA,2BAAuB;AAEvB,4CAA6D;AAC7D,sCAAgC;AAEhC;;;;;;GAMG;AACH;IAAA;IAiCA,CAAC;IAhCC;;;;;;;;OAQG;IACW,wBAAc,GAA5B,UACE,IAAS,EACT,MAAwB;QAExB,IAAI,KAAK,EAAE,cAAc,CAAA;QACzB,yCAAyC;QACzC,IAAI;YACF,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAkB,CAAA;SACrD;QAAC,OAAO,GAAqB,EAAE;YAC9B,IAAI,GAAG,YAAY,OAAC,CAAC,QAAQ;gBAAE,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;;gBACzD,KAAK,GAAG,2BAA2B,CAAA,CAAC,8BAA8B;SACxE;QACD,mBAAmB;QACnB,IAAI,CAAC,cAAc,IAAI,KAAK,EAAE;YAC5B,OAAO,kBAAQ,CAAC,kBAAkB,CAChC,iBAAO,CAAC,2BAA2B,EACnC,iBAAO,CAAC,sBAAsB,EAC9B,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAA;SACF;aAAM;YACL,OAAO,IAAI,CAAA;SACZ;IACH,CAAC;IACH,gBAAC;AAAD,CAAC,AAjCD,IAiCC"}
1
+ {"version":3,"file":"Validator.js","sourceRoot":"","sources":["../../../src/Validation/Validator.ts"],"names":[],"mappings":";;AAAA,2BAAuB;AAEvB,4CAA6D;AAC7D,sCAAgC;AAEhC;;;;;GAKG;AACH;IAAA;IAgCA,CAAC;IA/BC;;;;;OAKG;IACW,wBAAc,GAA5B,UACE,IAAS,EACT,MAA0C;QAE1C,IAAI,KAAK,EAAE,cAAc,CAAA;QAEzB,yCAAyC;QACzC,IAAI;YACF,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAkB,CAAA;SACrD;QAAC,OAAO,GAAqB,EAAE;YAC9B,IAAI,GAAG,YAAY,OAAC,CAAC,QAAQ;gBAAE,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;;gBACzD,KAAK,GAAG,2BAA2B,CAAA,CAAC,8BAA8B;SACxE;QAED,mBAAmB;QACnB,IAAI,CAAC,cAAc,IAAI,KAAK,EAAE;YAC5B,OAAO,kBAAQ,CAAC,kBAAkB,CAChC,iBAAO,CAAC,2BAA2B,EACnC,iBAAO,CAAC,sBAAsB,EAC9B,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAA;SACF;aAAM;YACL,OAAO,IAAI,CAAA;SACZ;IACH,CAAC;IACH,gBAAC;AAAD,CAAC,AAhCD,IAgCC"}
package/index.ts CHANGED
@@ -9,6 +9,21 @@ import JWT from './src/Crypto/JWT'
9
9
  import Mailer from './src/Mailer/Mailer'
10
10
  import Router, { Route } from './src/Server/Router'
11
11
 
12
+ /**
13
+ * Exported modules:
14
+ * - Transaction: A module for handling transactions.
15
+ * - Process: A module for managing processes.
16
+ * - EventProcessor: A module for processing events.
17
+ * - Router: A module for routing requests.
18
+ * - Mailer: A module for sending emails.
19
+ * - Crypto: A module for cryptographic operations.
20
+ * - JWT: A module for handling JSON Web Tokens.
21
+ * - Configuration: A module for managing configuration settings.
22
+ * - Response: A module for constructing HTTP responses.
23
+ * - Utils: A module containing utility functions.
24
+ * - Route: A module for defining routes.
25
+ * - ResponseErrorType: An enumeration of possible response error types.
26
+ */
12
27
  export {
13
28
  // Base Events
14
29
  Transaction,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creator.co/wapi",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -37,19 +37,24 @@
37
37
  "node-cache": "^5.1.2",
38
38
  "object-hash": "^3.0.0",
39
39
  "parse-duration": "^1.1.0",
40
+ "path-to-regexp": "^6.2.1",
40
41
  "pg": "^8.11.3",
41
42
  "sha1": "^1.1.1",
42
43
  "stack-trace": "0.0.10",
43
44
  "zod": "^3.22.4"
44
45
  },
45
46
  "devDependencies": {
47
+ "@jest/globals": "^29.7.0",
46
48
  "@types/aws-lambda": "^8.10.119",
47
49
  "@types/chai": "^4.3.9",
50
+ "@types/cors": "^2.8.15",
48
51
  "@types/express": "^4.17.19",
49
52
  "@types/jest": "^29.5.6",
50
53
  "@types/jsonwebtoken": "^9.0.3",
51
54
  "@types/node": "^20.5.7",
55
+ "@types/path-to-regexp": "^1.7.0",
52
56
  "@types/pg": "^8.10.5",
57
+ "@types/supertest": "^2.0.15",
53
58
  "@typescript-eslint/eslint-plugin": "^6.5.0",
54
59
  "@typescript-eslint/parser": "^6.5.0",
55
60
  "aws-lambda": "^1.0.7",
@@ -2,36 +2,28 @@ import type { Context, APIGatewayEvent } from 'aws-lambda'
2
2
 
3
3
  import Utils from './Utils'
4
4
  import Logger from '../Logger/Logger'
5
+
5
6
  /**
6
- * ${1:Description placeholder}
7
- *
8
- * @export
9
- * @class Request
10
- * @typedef {Request}
11
- * @template InputType
7
+ * Represents a request object with utility methods for accessing request information.
8
+ * @template InputType - The type of the request body.
12
9
  */
13
10
  export default class Request<InputType> {
14
11
  /**
15
- * ${1:Description placeholder}
16
- *
17
- * @private
12
+ * Represents an API Gateway event for a request.
18
13
  * @type {APIGatewayEvent}
19
14
  */
20
15
  private requestEvent: APIGatewayEvent
21
16
  /**
22
- * ${1:Description placeholder}
23
- *
24
- * @private
25
- * @type {Context}
17
+ * The context object for the current instance.
26
18
  */
27
19
  private context: Context
20
+
28
21
  /**
29
- * Creates an instance of Request.
30
- *
31
- * @constructor
32
- * @param {APIGatewayEvent} requestEvent
33
- * @param {Context} context
34
- * @param {Logger} logger
22
+ * Constructs a new instance of the class.
23
+ * @param {APIGatewayEvent} requestEvent - The API Gateway event object.
24
+ * @param {Context} context - The context object.
25
+ * @param {Logger} logger - The logger object.
26
+ * @returns None
35
27
  */
36
28
  constructor(requestEvent: APIGatewayEvent, context: Context, logger: Logger) {
37
29
  this.requestEvent = requestEvent
@@ -39,74 +31,66 @@ export default class Request<InputType> {
39
31
  logger.debug('Request info:', JSON.stringify(requestEvent))
40
32
  logger.debug('Request context:', JSON.stringify(context))
41
33
  }
34
+
42
35
  /**
43
- * ${1:Description placeholder}
44
- *
45
- * @public
46
- * @param {string} paramName
47
- * @returns {boolean}
36
+ * Checks if the given query parameter exists and has a valid value.
37
+ * @param {string} paramName - The name of the query parameter to check.
38
+ * @returns {boolean} - True if the query parameter exists and has a valid value, false otherwise.
48
39
  */
49
40
  public containsQueryParam(paramName: string): boolean {
50
41
  const val = this.getQueryParam(paramName)
51
42
  return !!val && (Utils.isValidString(val) || Utils.isValidNumber(val))
52
43
  }
44
+
53
45
  /**
54
- * ${1:Description placeholder}
55
- *
56
- * @public
57
- * @param {string} paramName
58
- * @returns {(string | null)}
46
+ * Retrieves the value of a query parameter from the request event's query string parameters.
47
+ * @param {string} paramName - The name of the query parameter to retrieve.
48
+ * @returns {string | null} The value of the query parameter, or null if it does not exist.
59
49
  */
60
50
  public getQueryParam(paramName: string): string | null {
61
51
  return Utils.caseInsensitiveObjectForKey(this.requestEvent.queryStringParameters, paramName)
62
52
  }
53
+
63
54
  /**
64
- * ${1:Description placeholder}
65
- *
66
- * @public
67
- * @param {string} headerName
68
- * @returns {(string | null)}
55
+ * Retrieves the value of the specified header from the request event headers.
56
+ * @param {string} headerName - The name of the header to retrieve.
57
+ * @returns {string | null} - The value of the header, or null if the header is not found.
69
58
  */
70
59
  public getHeader(headerName: string): string | null {
71
60
  return Utils.caseInsensitiveObjectForKey(this.requestEvent.headers, headerName)
72
61
  }
73
- //context params
62
+
74
63
  /**
75
- * ${1:Description placeholder}
76
- *
77
- * @public
78
- * @param {string} cxtParam
79
- * @returns {(any | null)}
64
+ * Retrieves the value of a context parameter from the request context object.
65
+ * @param {string} cxtParam - The name of the context parameter to retrieve.
66
+ * @returns The value of the context parameter, or null if it does not exist.
80
67
  */
81
68
  public getContextParam(cxtParam: string): any | null {
82
69
  return Utils.caseInsensitiveObjectForKey(this.requestEvent.requestContext, cxtParam)
83
70
  }
71
+
84
72
  /**
85
- * ${1:Description placeholder}
86
- *
87
- * @public
88
- * @param {string} paramName
89
- * @returns {boolean}
73
+ * Checks if the given parameter name exists in the path parameters and if its value is a valid string or number.
74
+ * @param {string} paramName - The name of the parameter to check.
75
+ * @returns {boolean} - True if the parameter exists and its value is a valid string or number, false otherwise.
90
76
  */
91
77
  public containsPathParam(paramName: string): boolean {
92
78
  const val = this.getPathParam(paramName)
93
79
  return !!val && (Utils.isValidString(val) || Utils.isValidNumber(val))
94
80
  }
81
+
95
82
  /**
96
- * ${1:Description placeholder}
97
- *
98
- * @public
99
- * @param {string} paramName
100
- * @returns {(string | null)}
83
+ * Retrieves the value of a path parameter from the request event.
84
+ * @param {string} paramName - The name of the path parameter to retrieve.
85
+ * @returns {string | null} The value of the path parameter, or null if it does not exist.
101
86
  */
102
87
  public getPathParam(paramName: string): string | null {
103
88
  return Utils.caseInsensitiveObjectForKey(this.requestEvent.pathParameters, paramName)
104
89
  }
90
+
105
91
  /**
106
- * ${1:Description placeholder}
107
- *
108
- * @public
109
- * @returns {InputType}
92
+ * Retrieves the body of the request event and parses it if it is a string.
93
+ * @returns {InputType} The parsed body of the request event.
110
94
  */
111
95
  public getBody(): InputType {
112
96
  let b: any = null
@@ -118,72 +102,70 @@ export default class Request<InputType> {
118
102
  }
119
103
  return b
120
104
  }
105
+
121
106
  /**
122
- * ${1:Description placeholder}
123
- *
124
- * @public
125
- * @returns {string}
107
+ * Retrieves the path from the request event.
108
+ * @returns {string} The path of the request event.
126
109
  */
127
110
  public getPath(): string {
128
111
  return this.requestEvent.path
129
112
  }
113
+
130
114
  /**
131
- * ${1:Description placeholder}
132
- *
133
- * @public
134
- * @returns {string}
115
+ * Retrieves the HTTP method of the current request.
116
+ * @returns {string} The HTTP method of the request.
135
117
  */
136
118
  public getMethod(): string {
137
119
  return this.requestEvent.httpMethod
138
120
  }
121
+
139
122
  /**
140
- * ${1:Description placeholder}
141
- *
142
- * @public
143
- * @returns {(object | null)}
123
+ * Retrieves the path parameters from the request event.
124
+ * @returns {object | null} - The path parameters object, or null if not found.
144
125
  */
145
126
  public getPathParams(): object | null {
146
127
  return this.requestEvent.pathParameters
147
128
  }
129
+
148
130
  /**
149
- * ${1:Description placeholder}
150
- *
151
- * @public
152
- * @returns {(string | null)}
131
+ * Retrieves the value of the 'Authorization' header from the request.
132
+ * @returns The value of the 'Authorization' header, or null if it is not present.
153
133
  */
154
134
  public getAuthorizationHeader(): string | null {
155
135
  return this.getHeader('Authorization')
156
136
  }
137
+
157
138
  /**
158
- * ${1:Description placeholder}
159
- *
160
- * @public
161
- * @returns {string}
139
+ * Retrieves the request ID associated with the current execution context.
140
+ * @returns {string} The request ID.
162
141
  */
163
142
  public getRequestID(): string {
164
143
  if (this.context.awsRequestId) return this.context.awsRequestId
165
144
  return this.requestEvent.requestContext ? this.requestEvent.requestContext.requestId : 'unknown'
166
145
  }
146
+
167
147
  /**
168
- * ${1:Description placeholder}
169
- *
170
- * @public
171
- * @returns {string}
148
+ * Retrieves the origin IP address of the request.
149
+ * @returns {string} The origin IP address. If the IP address is not available, it returns 'unknown'.
172
150
  */
173
151
  public getOriginIP(): string {
174
152
  const origin = this.getContextParam('identity')?.sourceIp
175
153
  const hOrigin = this.getHeader('X-Forwarded-For')
176
154
  return origin ? origin : hOrigin ? hOrigin : 'unknown'
177
155
  }
156
+
178
157
  /**
179
- * ${1:Description placeholder}
180
- *
181
- * @public
182
- * @param {any[]} keys
183
- * @param {any[]} result
158
+ * Sets the fixed path parameters in the request event object.
159
+ * @param {any[]} keys - An array of keys representing the path parameter names.
160
+ * @param {any[]} result - An array of values representing the path parameter values.
161
+ * @returns None
184
162
  */
185
163
  public setFixedPathParams(keys: any[], result: any[]): void {
186
164
  this.requestEvent.pathParameters = {}
187
- keys.forEach((key, index) => (this.requestEvent.pathParameters[key.name] = result[index + 1]))
165
+ keys.forEach((key, index) => {
166
+ if (this.requestEvent?.pathParameters) {
167
+ this.requestEvent.pathParameters[key.name] = result[index + 1]
168
+ }
169
+ })
188
170
  }
189
171
  }