@creator.co/wapi 1.2.11 → 1.3.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.
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/package.json +2 -1
- package/dist/src/API/Request.d.ts +26 -18
- package/dist/src/API/Request.js +27 -14
- package/dist/src/API/Request.js.map +1 -1
- package/dist/src/API/Response.d.ts +1 -1
- package/dist/src/API/Response.js.map +1 -1
- package/dist/src/BaseEvent/Transaction.d.ts +9 -3
- package/dist/src/BaseEvent/Transaction.js.map +1 -1
- package/dist/src/Database/Database.d.ts +1 -1
- package/dist/src/Database/index.d.ts +7 -0
- package/dist/src/Database/index.js +10 -0
- package/dist/src/Database/index.js.map +1 -0
- package/dist/src/Database/integrations/knex/KnexDatabase.d.ts +1 -0
- package/dist/src/Database/integrations/knex/KnexDatabase.js +9 -4
- package/dist/src/Database/integrations/knex/KnexDatabase.js.map +1 -1
- package/dist/src/Database/types.d.ts +47 -0
- package/dist/src/Database/types.js +3 -0
- package/dist/src/Database/types.js.map +1 -0
- package/dist/src/Server/Router.d.ts +18 -8
- package/dist/src/Server/Router.js.map +1 -1
- package/dist/src/Server/lib/Server.js +15 -1
- package/dist/src/Server/lib/Server.js.map +1 -1
- package/dist/src/Server/lib/container/GenericHandlerEvent.js +1 -3
- package/dist/src/Server/lib/container/GenericHandlerEvent.js.map +1 -1
- package/index.ts +2 -0
- package/package.json +2 -1
- package/src/API/Request.ts +38 -21
- package/src/API/Response.ts +1 -1
- package/src/BaseEvent/Transaction.ts +16 -4
- package/src/Database/Database.ts +1 -1
- package/src/Database/index.ts +15 -0
- package/src/Database/integrations/knex/KnexDatabase.ts +10 -2
- package/src/Database/{types.d.ts → types.ts} +7 -2
- package/src/Server/Router.ts +29 -8
- package/src/Server/lib/Server.ts +18 -1
- package/src/Server/lib/container/GenericHandlerEvent.ts +1 -3
- package/tests/API/Request.test.ts +8 -2
- package/tests/API/Utils.test.ts +10 -0
- package/tests/Database/integrations/knex/KnexDatabase.test.ts +23 -0
- package/tests/Database/integrations/knex/KnexTransaction.test.ts +1 -1
- package/tests/Server/lib/ContainerServer.test.ts +219 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import Transaction from './src/BaseEvent/Transaction';
|
|
|
7
7
|
import Configuration from './src/Config/Configuration';
|
|
8
8
|
import Crypto from './src/Crypto/Crypto';
|
|
9
9
|
import JWT from './src/Crypto/JWT';
|
|
10
|
+
import * as Database from './src/Database';
|
|
10
11
|
import Mailer from './src/Mailer/Mailer';
|
|
11
12
|
import Router, { Route } from './src/Server/Router';
|
|
12
13
|
/**
|
|
@@ -24,4 +25,4 @@ import Router, { Route } from './src/Server/Router';
|
|
|
24
25
|
* - Route: A module for defining routes.
|
|
25
26
|
* - ResponseErrorType: An enumeration of possible response error types.
|
|
26
27
|
*/
|
|
27
|
-
export { Transaction, Process, EventProcessor, Router, Mailer, Crypto, JWT, Configuration, Response, Utils, Route, ResponseErrorType, HttpMethod, };
|
|
28
|
+
export { Transaction, Process, EventProcessor, Router, Mailer, Crypto, JWT, Configuration, Response, Utils, Route, ResponseErrorType, HttpMethod, Database, };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpMethod = exports.Utils = exports.Response = exports.Configuration = exports.JWT = exports.Crypto = exports.Mailer = exports.Router = exports.EventProcessor = exports.Process = exports.Transaction = void 0;
|
|
3
|
+
exports.Database = exports.HttpMethod = exports.Utils = exports.Response = exports.Configuration = exports.JWT = exports.Crypto = exports.Mailer = exports.Router = exports.EventProcessor = exports.Process = exports.Transaction = void 0;
|
|
4
4
|
var Request_1 = require("./src/API/Request");
|
|
5
5
|
Object.defineProperty(exports, "HttpMethod", { enumerable: true, get: function () { return Request_1.HttpMethod; } });
|
|
6
6
|
var Response_1 = require("./src/API/Response");
|
|
@@ -19,6 +19,8 @@ var Crypto_1 = require("./src/Crypto/Crypto");
|
|
|
19
19
|
exports.Crypto = Crypto_1.default;
|
|
20
20
|
var JWT_1 = require("./src/Crypto/JWT");
|
|
21
21
|
exports.JWT = JWT_1.default;
|
|
22
|
+
var Database = require("./src/Database");
|
|
23
|
+
exports.Database = Database;
|
|
22
24
|
var Mailer_1 = require("./src/Mailer/Mailer");
|
|
23
25
|
exports.Mailer = Mailer_1.default;
|
|
24
26
|
var Router_1 = require("./src/Server/Router");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,6CAA8C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,6CAA8C;AA8C5C,2FA9CO,oBAAU,OA8CP;AA7CZ,+CAAgE;AAuC9D,mBAvCK,kBAAQ,CAuCL;AAtCV,yCAAmC;AAwCjC,gBAxCK,eAAK,CAwCL;AAvCP,iEAA2D;AA6BzD,yBA7BK,wBAAc,CA6BL;AA5BhB,mDAA6C;AA2B3C,kBA3BK,iBAAO,CA2BL;AA1BT,2DAAqD;AAyBnD,sBAzBK,qBAAW,CAyBL;AAxBb,4DAAsD;AAgCpD,wBAhCK,uBAAa,CAgCL;AA/Bf,8CAAwC;AA6BtC,iBA7BK,gBAAM,CA6BL;AA5BR,wCAAkC;AA6BhC,cA7BK,aAAG,CA6BL;AA5BL,yCAA0C;AAsCxC,4BAAQ;AArCV,8CAAwC;AAyBtC,iBAzBK,gBAAM,CAyBL;AAxBR,8CAAmD;AAsBjD,iBAtBK,gBAAM,CAsBL"}
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@creator.co/wapi",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"json-stringify-safe": "^5.0.1",
|
|
35
35
|
"jsonwebtoken": "^9.0.2",
|
|
36
36
|
"knex": "^3.0.1",
|
|
37
|
+
"knex-stringcase": "^1.4.6",
|
|
37
38
|
"node-cache": "^5.1.2",
|
|
38
39
|
"object-hash": "^3.0.0",
|
|
39
40
|
"parse-duration": "^1.1.0",
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { Context, APIGatewayEvent } from 'aws-lambda';
|
|
2
2
|
import Logger from '../Logger/Logger';
|
|
3
3
|
/**
|
|
4
|
-
* Represents a request object with
|
|
5
|
-
* @
|
|
4
|
+
* Represents a request object with generic types for input, query parameters, and path parameters.
|
|
5
|
+
* @class Request
|
|
6
|
+
* @template InputType - The type of the input data for the request.
|
|
7
|
+
* @template PathParamsType - The type of the path parameters for the request.
|
|
8
|
+
* @template QueryParamsType - The type of the query parameters for the request.
|
|
6
9
|
*/
|
|
7
|
-
export default class Request<InputType> {
|
|
10
|
+
export default class Request<InputType, PathParamsType, QueryParamsType> {
|
|
8
11
|
/**
|
|
9
12
|
* Represents an API Gateway event for a request.
|
|
10
13
|
* @type {APIGatewayEvent}
|
|
@@ -23,17 +26,17 @@ export default class Request<InputType> {
|
|
|
23
26
|
*/
|
|
24
27
|
constructor(requestEvent: APIGatewayEvent, context: Context, logger: Logger);
|
|
25
28
|
/**
|
|
26
|
-
* Checks if the
|
|
27
|
-
* @param {
|
|
29
|
+
* Checks if the specified query parameter exists and has a valid value.
|
|
30
|
+
* @param {keyof QueryParamsType} paramName - The name of the query parameter to check.
|
|
28
31
|
* @returns {boolean} - True if the query parameter exists and has a valid value, false otherwise.
|
|
29
32
|
*/
|
|
30
|
-
containsQueryParam(paramName:
|
|
33
|
+
containsQueryParam(paramName: keyof QueryParamsType): boolean;
|
|
31
34
|
/**
|
|
32
|
-
* Retrieves the value of a query parameter from the
|
|
33
|
-
* @param {
|
|
35
|
+
* Retrieves the value of a query parameter from the URL.
|
|
36
|
+
* @param {keyof QueryParamsType} paramName - The name of the query parameter to retrieve.
|
|
34
37
|
* @returns {string | null} The value of the query parameter, or null if it does not exist.
|
|
35
38
|
*/
|
|
36
|
-
getQueryParam(paramName:
|
|
39
|
+
getQueryParam(paramName: keyof QueryParamsType): string | null;
|
|
37
40
|
/**
|
|
38
41
|
* Retrieves the value of the specified header from the request event headers.
|
|
39
42
|
* @param {string} headerName - The name of the header to retrieve.
|
|
@@ -47,17 +50,17 @@ export default class Request<InputType> {
|
|
|
47
50
|
*/
|
|
48
51
|
getContextParam(cxtParam: string): any | null;
|
|
49
52
|
/**
|
|
50
|
-
* Checks if the given parameter name exists in the
|
|
51
|
-
* @param {
|
|
52
|
-
* @returns {boolean} - True if the parameter exists
|
|
53
|
+
* Checks if the given parameter name exists in the PathParamsType object.
|
|
54
|
+
* @param {keyof PathParamsType} paramName - The name of the parameter to check.
|
|
55
|
+
* @returns {boolean} - True if the parameter exists, false otherwise.
|
|
53
56
|
*/
|
|
54
|
-
containsPathParam(paramName:
|
|
57
|
+
containsPathParam(paramName: keyof PathParamsType): boolean;
|
|
55
58
|
/**
|
|
56
|
-
* Retrieves the value of a path parameter from the
|
|
57
|
-
* @param {
|
|
59
|
+
* Retrieves the value of a specific path parameter from the URL.
|
|
60
|
+
* @param {keyof PathParamsType} paramName - The name of the path parameter to retrieve.
|
|
58
61
|
* @returns {string | null} The value of the path parameter, or null if it does not exist.
|
|
59
62
|
*/
|
|
60
|
-
getPathParam(paramName:
|
|
63
|
+
getPathParam(paramName: keyof PathParamsType): string | null;
|
|
61
64
|
/**
|
|
62
65
|
* Retrieves the body of the request event and parses it if it is a string.
|
|
63
66
|
* @returns {InputType} The parsed body of the request event.
|
|
@@ -75,9 +78,14 @@ export default class Request<InputType> {
|
|
|
75
78
|
getMethod(): HttpMethod;
|
|
76
79
|
/**
|
|
77
80
|
* Retrieves the path parameters from the request event.
|
|
78
|
-
* @returns {
|
|
81
|
+
* @returns {PathParamsType | null} - The path parameters object, or null if not found.
|
|
79
82
|
*/
|
|
80
|
-
getPathParams():
|
|
83
|
+
getPathParams(): PathParamsType | null;
|
|
84
|
+
/**
|
|
85
|
+
* Retrieves the query parameters from the request event.
|
|
86
|
+
* @returns {QueryParamsType | null} - The query parameters object, or null if not found.
|
|
87
|
+
*/
|
|
88
|
+
getQueryParams(): QueryParamsType | null;
|
|
81
89
|
/**
|
|
82
90
|
* Retrieves the value of the 'Authorization' header from the request.
|
|
83
91
|
* @returns The value of the 'Authorization' header, or null if it is not present.
|
package/dist/src/API/Request.js
CHANGED
|
@@ -3,8 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.HttpMethod = void 0;
|
|
4
4
|
var Utils_1 = require("./Utils");
|
|
5
5
|
/**
|
|
6
|
-
* Represents a request object with
|
|
7
|
-
* @
|
|
6
|
+
* Represents a request object with generic types for input, query parameters, and path parameters.
|
|
7
|
+
* @class Request
|
|
8
|
+
* @template InputType - The type of the input data for the request.
|
|
9
|
+
* @template PathParamsType - The type of the path parameters for the request.
|
|
10
|
+
* @template QueryParamsType - The type of the query parameters for the request.
|
|
8
11
|
*/
|
|
9
12
|
var Request = /** @class */ (function () {
|
|
10
13
|
/**
|
|
@@ -21,8 +24,8 @@ var Request = /** @class */ (function () {
|
|
|
21
24
|
logger.debug('Request context:', JSON.stringify(context));
|
|
22
25
|
}
|
|
23
26
|
/**
|
|
24
|
-
* Checks if the
|
|
25
|
-
* @param {
|
|
27
|
+
* Checks if the specified query parameter exists and has a valid value.
|
|
28
|
+
* @param {keyof QueryParamsType} paramName - The name of the query parameter to check.
|
|
26
29
|
* @returns {boolean} - True if the query parameter exists and has a valid value, false otherwise.
|
|
27
30
|
*/
|
|
28
31
|
Request.prototype.containsQueryParam = function (paramName) {
|
|
@@ -30,12 +33,12 @@ var Request = /** @class */ (function () {
|
|
|
30
33
|
return !!val && (Utils_1.default.isValidString(val) || Utils_1.default.isValidNumber(val));
|
|
31
34
|
};
|
|
32
35
|
/**
|
|
33
|
-
* Retrieves the value of a query parameter from the
|
|
34
|
-
* @param {
|
|
36
|
+
* Retrieves the value of a query parameter from the URL.
|
|
37
|
+
* @param {keyof QueryParamsType} paramName - The name of the query parameter to retrieve.
|
|
35
38
|
* @returns {string | null} The value of the query parameter, or null if it does not exist.
|
|
36
39
|
*/
|
|
37
40
|
Request.prototype.getQueryParam = function (paramName) {
|
|
38
|
-
return Utils_1.default.caseInsensitiveObjectForKey(this.requestEvent.queryStringParameters, paramName);
|
|
41
|
+
return Utils_1.default.caseInsensitiveObjectForKey(this.requestEvent.queryStringParameters, String(paramName));
|
|
39
42
|
};
|
|
40
43
|
/**
|
|
41
44
|
* Retrieves the value of the specified header from the request event headers.
|
|
@@ -54,21 +57,21 @@ var Request = /** @class */ (function () {
|
|
|
54
57
|
return Utils_1.default.caseInsensitiveObjectForKey(this.requestEvent.requestContext, cxtParam);
|
|
55
58
|
};
|
|
56
59
|
/**
|
|
57
|
-
* Checks if the given parameter name exists in the
|
|
58
|
-
* @param {
|
|
59
|
-
* @returns {boolean} - True if the parameter exists
|
|
60
|
+
* Checks if the given parameter name exists in the PathParamsType object.
|
|
61
|
+
* @param {keyof PathParamsType} paramName - The name of the parameter to check.
|
|
62
|
+
* @returns {boolean} - True if the parameter exists, false otherwise.
|
|
60
63
|
*/
|
|
61
64
|
Request.prototype.containsPathParam = function (paramName) {
|
|
62
65
|
var val = this.getPathParam(paramName);
|
|
63
66
|
return !!val && (Utils_1.default.isValidString(val) || Utils_1.default.isValidNumber(val));
|
|
64
67
|
};
|
|
65
68
|
/**
|
|
66
|
-
* Retrieves the value of a path parameter from the
|
|
67
|
-
* @param {
|
|
69
|
+
* Retrieves the value of a specific path parameter from the URL.
|
|
70
|
+
* @param {keyof PathParamsType} paramName - The name of the path parameter to retrieve.
|
|
68
71
|
* @returns {string | null} The value of the path parameter, or null if it does not exist.
|
|
69
72
|
*/
|
|
70
73
|
Request.prototype.getPathParam = function (paramName) {
|
|
71
|
-
return Utils_1.default.caseInsensitiveObjectForKey(this.requestEvent.pathParameters, paramName);
|
|
74
|
+
return Utils_1.default.caseInsensitiveObjectForKey(this.requestEvent.pathParameters, String(paramName));
|
|
72
75
|
};
|
|
73
76
|
/**
|
|
74
77
|
* Retrieves the body of the request event and parses it if it is a string.
|
|
@@ -108,11 +111,21 @@ var Request = /** @class */ (function () {
|
|
|
108
111
|
};
|
|
109
112
|
/**
|
|
110
113
|
* Retrieves the path parameters from the request event.
|
|
111
|
-
* @returns {
|
|
114
|
+
* @returns {PathParamsType | null} - The path parameters object, or null if not found.
|
|
112
115
|
*/
|
|
113
116
|
Request.prototype.getPathParams = function () {
|
|
117
|
+
// type conversion guaranteed by validation
|
|
114
118
|
return this.requestEvent.pathParameters;
|
|
115
119
|
};
|
|
120
|
+
/**
|
|
121
|
+
* Retrieves the query parameters from the request event.
|
|
122
|
+
* @returns {QueryParamsType | null} - The query parameters object, or null if not found.
|
|
123
|
+
*/
|
|
124
|
+
Request.prototype.getQueryParams = function () {
|
|
125
|
+
// type conversion guaranteed by validation
|
|
126
|
+
console.log(this.requestEvent.queryStringParameters);
|
|
127
|
+
return this.requestEvent.queryStringParameters;
|
|
128
|
+
};
|
|
116
129
|
/**
|
|
117
130
|
* Retrieves the value of the 'Authorization' header from the request.
|
|
118
131
|
* @returns The value of the 'Authorization' header, or null if it is not present.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Request.js","sourceRoot":"","sources":["../../../src/API/Request.ts"],"names":[],"mappings":";;;AAEA,iCAA2B;AAG3B
|
|
1
|
+
{"version":3,"file":"Request.js","sourceRoot":"","sources":["../../../src/API/Request.ts"],"names":[],"mappings":";;;AAEA,iCAA2B;AAG3B;;;;;;GAMG;AACH;IAWE;;;;;;OAMG;IACH,iBAAY,YAA6B,EAAE,OAAgB,EAAE,MAAc;QACzE,IAAI,CAAC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,UAUX;AAVD,WAAY,UAAU;IACpB,yBAAW,CAAA;IACX,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,yBAAW,CAAA;IACX,+BAAiB,CAAA;IACjB,iCAAmB,CAAA;IACnB,iCAAmB,CAAA;IACnB,6BAAe,CAAA;IACf,6BAAe,CAAA;AACjB,CAAC,EAVW,UAAU,0BAAV,UAAU,QAUrB"}
|
|
@@ -104,7 +104,7 @@ export default class Response<BodyType = null> {
|
|
|
104
104
|
* @param {boolean} optDoNotCallContext - Optional flag to indicate whether to call the context or not.
|
|
105
105
|
* @returns {Promise<void>} - A promise that resolves when the response is built.
|
|
106
106
|
*/
|
|
107
|
-
build(context: Context, transaction: Transaction<any, any, any>, optDoNotCallContext: boolean): Promise<void>;
|
|
107
|
+
build(context: Context, transaction: Transaction<any, any, any, any, any>, optDoNotCallContext: boolean): Promise<void>;
|
|
108
108
|
/**
|
|
109
109
|
* Private method that pipes the response to the given context.
|
|
110
110
|
* @param {Context} context - The context object provided by AWS Lambda.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Response.js","sourceRoot":"","sources":["../../../src/API/Response.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,sCAAgC;AAEhC;;;;;;;GAOG;AACH;IAA0B,+BAAK;IAC7B,qBAAY,IAAS;QAArB,YACE,kBAAM,IAAI,CAAC,OAAO,IAAI,gBAAgB,CAAC,SAExC;QADC,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,IAAI,cAAc,CAAA;;IAC1C,CAAC;IACH,kBAAC;AAAD,CAAC,AALD,CAA0B,KAAK,GAK9B;AAaD;;;GAGG;AACH;IA4CE;;;;;;;;;OASG;IACH,kBACE,UAAkB,EAClB,IAAc,EACd,YAOa;QAEb,WAAW;QACX,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,IAAI,GAA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AG,EAAE,IAAI,CAAC,CAAA;QAC9D,OAAO,IAAI,CAAA;IACb,CAAC;IACH,eAAC;AAAD,CAAC,AAtUD,IAsUC"}
|
|
@@ -24,13 +24,19 @@ export type TransactionConfig = {
|
|
|
24
24
|
logger?: LoggerConfig;
|
|
25
25
|
publisher?: PublisherConfig;
|
|
26
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Represents a simple string dictionary with string values
|
|
29
|
+
*/
|
|
30
|
+
export type StringMap = {
|
|
31
|
+
[key: string]: string | null;
|
|
32
|
+
};
|
|
27
33
|
/**
|
|
28
34
|
* Represents a transaction object that handles the execution of a request and manages the response.
|
|
29
35
|
* @template InputType - The type of the input data for the transaction.
|
|
30
36
|
* @template ResponseInnerType - The type of the inner response data for the transaction.
|
|
31
37
|
* @template MiscRespType - The type of miscellaneous response data for the transaction.
|
|
32
38
|
*/
|
|
33
|
-
export default class Transaction<InputType = object, ResponseInnerType = null, MiscRespType = null> {
|
|
39
|
+
export default class Transaction<InputType = object, ResponseInnerType = null, MiscRespType = null, QueryParamsType = StringMap, PathParamsType = StringMap> {
|
|
34
40
|
/**
|
|
35
41
|
* The instance of the DatabaseManager class used for managing the database.
|
|
36
42
|
*/
|
|
@@ -74,7 +80,7 @@ export default class Transaction<InputType = object, ResponseInnerType = null, M
|
|
|
74
80
|
* The request object for making a request of type InputType.
|
|
75
81
|
* @readonly
|
|
76
82
|
*/
|
|
77
|
-
readonly request: Request<InputType>;
|
|
83
|
+
readonly request: Request<InputType, PathParamsType, QueryParamsType>;
|
|
78
84
|
/**
|
|
79
85
|
* The publisher of the content.
|
|
80
86
|
*/
|
|
@@ -99,7 +105,7 @@ export default class Transaction<InputType = object, ResponseInnerType = null, M
|
|
|
99
105
|
* @param {TransactionExecution<Transaction<InputType, ResponseInnerType, MiscRespType>, ResponseInnerType, MiscRespType>} executionFunc - The execution function to be executed.
|
|
100
106
|
* @returns {Promise<Response<ResponseInnerType | ResponseErrorType> | MiscRespType>} - A promise that resolves to the response or miscellaneous response.
|
|
101
107
|
*/
|
|
102
|
-
execute(executionFunc: TransactionExecution<Transaction<InputType, ResponseInnerType, MiscRespType>, ResponseInnerType, MiscRespType>): Promise<Response<ResponseInnerType | ResponseErrorType> | MiscRespType | null>;
|
|
108
|
+
execute(executionFunc: TransactionExecution<Transaction<InputType, ResponseInnerType, MiscRespType, QueryParamsType, PathParamsType>, ResponseInnerType, MiscRespType>): Promise<Response<ResponseInnerType | ResponseErrorType> | MiscRespType | null>;
|
|
103
109
|
/**
|
|
104
110
|
* Executes a transaction using the provided execution function and handles the response.
|
|
105
111
|
* @param {TransactionExecution<Transaction<InputType, ResponseInnerType, MiscRespType>, ResponseInnerType, MiscRespType>} executionFunc - The function to execute the transaction.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../../src/BaseEvent/Transaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,0CAAoC;AACpC,4CAA6D;AAC7D,+DAA6D;AAG7D,sCAAgC;AAChC,2CAAuD;AACvD,oDAAmE;
|
|
1
|
+
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../../src/BaseEvent/Transaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,0CAAoC;AACpC,4CAA6D;AAC7D,+DAA6D;AAG7D,sCAAgC;AAChC,2CAAuD;AACvD,oDAAmE;AAgCnE;;;;;GAKG;AACH;IA8DE;;;;;;OAMG;IACH,qBAAY,KAAiC,EAAE,OAAgB,EAAE,MAA0B;QA9D3F;;WAEG;QACK,oBAAe,GAAoB,iCAAe,CAAC,QAAQ,CAAA;QACnE;;;WAGG;QACK,iBAAY,GAA0B,EAAE,CAAA;QAuD9C,IAAM,aAAa,GAAG,O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AAI,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;;;;;;KAEzC;IAED;;;;;OAKG;IACK,sCAAgB,GAAxB,UAAyB,KAAa,EAAE,IAAY;QAClD,OAAO,kBAAQ,CAAC,8BAA8B,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IAC7D,CAAC;IACH,kBAAC;AAAD,CAAC,AAvPD,IAuPC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Database } from './Database';
|
|
2
|
+
import { DatabaseManager } from './DatabaseManager';
|
|
3
|
+
import { DatabaseTransaction } from './DatabaseTransaction';
|
|
4
|
+
import { KnexTransaction } from './integrations/knex/KnexTransaction';
|
|
5
|
+
import { PostgresTransaction } from './integrations/pgsql/PostgresTransaction';
|
|
6
|
+
import { DbConfig } from './types';
|
|
7
|
+
export { DatabaseTransaction, DbConfig, KnexTransaction, PostgresTransaction, DatabaseManager, Database, };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Database = exports.DatabaseManager = exports.DatabaseTransaction = void 0;
|
|
4
|
+
var Database_1 = require("./Database");
|
|
5
|
+
Object.defineProperty(exports, "Database", { enumerable: true, get: function () { return Database_1.Database; } });
|
|
6
|
+
var DatabaseManager_1 = require("./DatabaseManager");
|
|
7
|
+
Object.defineProperty(exports, "DatabaseManager", { enumerable: true, get: function () { return DatabaseManager_1.DatabaseManager; } });
|
|
8
|
+
var DatabaseTransaction_1 = require("./DatabaseTransaction");
|
|
9
|
+
Object.defineProperty(exports, "DatabaseTransaction", { enumerable: true, get: function () { return DatabaseTransaction_1.DatabaseTransaction; } });
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Database/index.ts"],"names":[],"mappings":";;;AAAA,uCAAqC;AAanC,yFAbO,mBAAQ,OAaP;AAZV,qDAAmD;AAWjD,gGAXO,iCAAe,OAWP;AAVjB,6DAA2D;AAMzD,oGANO,yCAAmB,OAMP"}
|
|
@@ -14,6 +14,7 @@ export declare class KnexDatabase extends Database<KnexTransaction> {
|
|
|
14
14
|
* @returns None
|
|
15
15
|
*/
|
|
16
16
|
constructor(config: DbConfig<'knex'>);
|
|
17
|
+
private constructConfig;
|
|
17
18
|
/**
|
|
18
19
|
* Initiates a transaction using the underlying database client.
|
|
19
20
|
* @returns {Promise<KnexTransaction>} A promise that resolves to a KnexTransaction object representing the transaction.
|
|
@@ -53,6 +53,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
53
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
54
|
exports.KnexDatabase = void 0;
|
|
55
55
|
var knex_1 = require("knex");
|
|
56
|
+
var knexStringcase = require("knex-stringcase");
|
|
56
57
|
var KnexTransaction_1 = require("./KnexTransaction");
|
|
57
58
|
var Database_1 = require("../../Database");
|
|
58
59
|
/**
|
|
@@ -68,7 +69,11 @@ var KnexDatabase = /** @class */ (function (_super) {
|
|
|
68
69
|
*/
|
|
69
70
|
function KnexDatabase(config) {
|
|
70
71
|
var _this = _super.call(this, config) || this;
|
|
71
|
-
_this.client = KnexDatabase.knexProvider(
|
|
72
|
+
_this.client = KnexDatabase.knexProvider(_this.constructConfig(config));
|
|
73
|
+
return _this;
|
|
74
|
+
}
|
|
75
|
+
KnexDatabase.prototype.constructConfig = function (config) {
|
|
76
|
+
var knexConfig = {
|
|
72
77
|
client: config.driver,
|
|
73
78
|
connection: {
|
|
74
79
|
host: config.host,
|
|
@@ -81,9 +86,9 @@ var KnexDatabase = /** @class */ (function (_super) {
|
|
|
81
86
|
min: 1,
|
|
82
87
|
max: config.maxConnections,
|
|
83
88
|
},
|
|
84
|
-
}
|
|
85
|
-
return
|
|
86
|
-
}
|
|
89
|
+
};
|
|
90
|
+
return config.convertCamelToSnake ? knexStringcase(knexConfig) : knexConfig;
|
|
91
|
+
};
|
|
87
92
|
/**
|
|
88
93
|
* Initiates a transaction using the underlying database client.
|
|
89
94
|
* @returns {Promise<KnexTransaction>} A promise that resolves to a KnexTransaction object representing the transaction.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KnexDatabase.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/knex/KnexDatabase.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAiC;
|
|
1
|
+
{"version":3,"file":"KnexDatabase.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/knex/KnexDatabase.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAiC;AACjC,gDAAiD;AAEjD,qDAAwE;AACxE,2CAAyC;AAGzC;;;GAGG;AACH;IAAkC,gCAAyB;IAKzD;;;;OAIG;IACH,sBAAmB,MAAwB;QAA3C,YACE,kBAAM,MAAM,CAAC,SAGd;QADC,KAAI,CAAC,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,KAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAA;;IACvE,CAAC;IAEO,sCAAe,GAAvB,UAAwB,MAAwB;QAC9C,IAAM,UAAU,GAAG;YACjB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,UAAU,EAAE;gBACV,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,IAAI,EAAE,MAAM,CAAC,QAAQ;gBACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;aAC1B;YACD,IAAI,EAAE;gBACJ,GAAG,EAAE,CAAC;gBACN,GAAG,EAAE,MAAM,CAAC,cAAc;aAC3B;SACF,CAAA;QAED,OAAO,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAA;IAC7E,CAAC;IAED;;;OAGG;IACmB,kCAAW,GAAjC;;;;;4BACmB,qBAAM,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,EAAA;;wBAA1C,QAAQ,GAAG,SAA+B;wBAChD,sBAAO,qCAAmB,CAAC,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAA;;;;KACxD;IAzCc,yBAAY,GAAiE,cAAI,CAAA;IA0ClG,mBAAC;CAAA,AA3CD,CAAkC,mBAAQ,GA2CzC;AA3CY,oCAAY"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Database } from './Database';
|
|
2
|
+
import { DATABASES } from './DatabaseManager';
|
|
3
|
+
/**
|
|
4
|
+
* Represents the available types of databases.
|
|
5
|
+
* @typedef {keyof typeof DATABASES} DatabaseType
|
|
6
|
+
*/
|
|
7
|
+
export type DatabaseType = keyof typeof DATABASES;
|
|
8
|
+
/**
|
|
9
|
+
* Represents the instance type of the specified database implementation.
|
|
10
|
+
* @param {Type} Type - The type of the database implementation.
|
|
11
|
+
*/
|
|
12
|
+
export type DatabaseImplType<Type extends DatabaseType> = InstanceType<(typeof DATABASES)[Type]>;
|
|
13
|
+
/**
|
|
14
|
+
* Defines a type for a database transaction based on the specified database type.
|
|
15
|
+
* @param {Type} - The database type.
|
|
16
|
+
* @returns The transaction type associated with the specified database type.
|
|
17
|
+
*/
|
|
18
|
+
export type DatabaseTransactionType<Type extends DatabaseType> = DatabaseImplType<Type> extends Database<infer TransactionType> ? TransactionType : never;
|
|
19
|
+
/**
|
|
20
|
+
* Represents the configuration for a database connection.
|
|
21
|
+
* @template S - The type of the database (e.g. "mysql", "postgres", etc.)
|
|
22
|
+
* @interface DbConfig
|
|
23
|
+
* @property {S} type - The type of the database.
|
|
24
|
+
* @property {string} driver - The driver to use for the database connection.
|
|
25
|
+
* @property {string} host - The host of the database server.
|
|
26
|
+
* @property {number} port - The port number of the database server.
|
|
27
|
+
* @property {string} username - The username for the database connection.
|
|
28
|
+
* @property {string} password - The password for the database connection.
|
|
29
|
+
* @property {string} database - The name of the database to connect to.
|
|
30
|
+
* @property {boolean} autoCommit - Whether or not to automatically commit transactions.
|
|
31
|
+
* @property {number} maxConnections - The maximum number of connections to the database.
|
|
32
|
+
* @property {boolean} [convertCamelToSnake] - Whether or not to convert camel case to snake case for column names.
|
|
33
|
+
* @returns The transaction type associated with the specified database type.
|
|
34
|
+
*/
|
|
35
|
+
export type DbConfig<S extends DatabaseType> = {
|
|
36
|
+
type: S;
|
|
37
|
+
driver: string;
|
|
38
|
+
host: string;
|
|
39
|
+
port: number;
|
|
40
|
+
username: string;
|
|
41
|
+
password: string;
|
|
42
|
+
database: string;
|
|
43
|
+
autoCommit: boolean;
|
|
44
|
+
maxConnections: number;
|
|
45
|
+
} & (S extends 'knex' ? {
|
|
46
|
+
convertCamelToSnake?: boolean;
|
|
47
|
+
} : any);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/Database/types.ts"],"names":[],"mappings":""}
|
|
@@ -4,7 +4,7 @@ import * as express from 'express';
|
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { HttpMethod } from '../API/Request';
|
|
6
6
|
import { ResponseErrorType } from '../API/Response';
|
|
7
|
-
import Transaction, { TransactionConfig, TransactionExecution } from '../BaseEvent/Transaction';
|
|
7
|
+
import Transaction, { TransactionConfig, TransactionExecution, StringMap } from '../BaseEvent/Transaction';
|
|
8
8
|
/**
|
|
9
9
|
* Represents a route in an API.
|
|
10
10
|
* @template InputType - The type of the input data for the route.
|
|
@@ -14,7 +14,7 @@ import Transaction, { TransactionConfig, TransactionExecution } from '../BaseEve
|
|
|
14
14
|
* @property {TransactionExecution<Transaction<InputType, OutputType | ResponseErrorType>, OutputType | ResponseErrorType>} handler - The handler function for the route.
|
|
15
15
|
* @property {z.ZodObject<any>} [inputSchema] - The input schema for validating the input data.
|
|
16
16
|
*/
|
|
17
|
-
export interface Route<InputType = any, OutputType = any> {
|
|
17
|
+
export interface Route<InputType = any, OutputType = any, PathParamsType = StringMap, QueryParamsType = StringMap> {
|
|
18
18
|
/**
|
|
19
19
|
* Represents a file path as a string.
|
|
20
20
|
* @param {string} path - The file path.
|
|
@@ -28,21 +28,31 @@ export interface Route<InputType = any, OutputType = any> {
|
|
|
28
28
|
method: HttpMethod;
|
|
29
29
|
/**
|
|
30
30
|
* Represents a handler for executing a transaction with the given input type and output type.
|
|
31
|
-
* @param {Transaction<InputType, OutputType | ResponseErrorType>} transaction - The transaction to execute.
|
|
31
|
+
* @param {Transaction<InputType, OutputType | ResponseErrorType, PathParamsType, QueryParamsType>} transaction - The transaction to execute.
|
|
32
32
|
* @param {OutputType | ResponseErrorType} - The output type or response error type of the transaction.
|
|
33
33
|
*/
|
|
34
|
-
handler: TransactionExecution<Transaction<InputType, OutputType | ResponseErrorType>, OutputType | ResponseErrorType>;
|
|
34
|
+
handler: TransactionExecution<Transaction<InputType, OutputType | ResponseErrorType, null, PathParamsType, QueryParamsType>, OutputType | ResponseErrorType>;
|
|
35
35
|
/**
|
|
36
|
-
<<<<<<< HEAD
|
|
37
36
|
* An optional input schema for validating the structure of the input data.
|
|
38
|
-
* @type {z.ZodObject<any>}
|
|
39
|
-
=======
|
|
40
37
|
* Description placeholder
|
|
41
38
|
*
|
|
42
39
|
* @type {?z.ZodObject<any> | z.ZodUnion<any>}
|
|
43
|
-
>>>>>>> 65ffb67 (Improve syntax with tighther eslint, fix lots of test errors, new proxy containerSetupHook and improved validation type)
|
|
44
40
|
*/
|
|
45
41
|
inputSchema?: z.ZodObject<any> | z.ZodUnion<any>;
|
|
42
|
+
/**
|
|
43
|
+
* An optional input schema for validating the structure of the path params.
|
|
44
|
+
* Description placeholder
|
|
45
|
+
*
|
|
46
|
+
* @type {?z.ZodObject<any> | z.ZodUnion<any>}
|
|
47
|
+
*/
|
|
48
|
+
pathSchema?: z.ZodObject<any> | z.ZodUnion<any>;
|
|
49
|
+
/**
|
|
50
|
+
* An optional input schema for validating the structure of the query params.
|
|
51
|
+
* Description placeholder
|
|
52
|
+
*
|
|
53
|
+
* @type {?z.ZodObject<any> | z.ZodUnion<any>}
|
|
54
|
+
*/
|
|
55
|
+
querySchema?: z.ZodObject<any> | z.ZodUnion<any>;
|
|
46
56
|
}
|
|
47
57
|
/**
|
|
48
58
|
* Represents the configuration options for a router.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Router.js","sourceRoot":"","sources":["../../../src/Server/Router.ts"],"names":[],"mappings":";;AAKA,yDAAmD;AACnD,uCAAiC;AAGjC,sCAAgC;
|
|
1
|
+
{"version":3,"file":"Router.js","sourceRoot":"","sources":["../../../src/Server/Router.ts"],"names":[],"mappings":";;AAKA,yDAAmD;AACnD,uCAAiC;AAGjC,sCAAgC;AA6HhC;;GAEG;AACH;IAUE;;;;OAIG;IACH,gBAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,yBAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,gBAAM,CAAC,MAAM,CAAC,CAAA;IACrF,CAAC;IAED;;;OAGG;IACI,0BAAS,GAAhB;QACE,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAA;IAChC,CAAC;IAED;;;OAGG;IACK,4BAAW,GAAnB;QACE,OAAO,eAAK,CAAC,qBAAqB,EAAE,CAAA;IACtC,CAAC;IACH,aAAC;AAAD,CAAC,AAnCD,IAmCC"}
|
|
@@ -75,7 +75,7 @@ var Server = /** @class */ (function () {
|
|
|
75
75
|
case 0:
|
|
76
76
|
// init transaction
|
|
77
77
|
return [4 /*yield*/, new Transaction_1.default(event, context, this.config).execute(function (transaction) { return __awaiter(_this, void 0, void 0, function () {
|
|
78
|
-
var request, route, validationResp;
|
|
78
|
+
var request, route, validationResp, validationResp, validationResp;
|
|
79
79
|
return __generator(this, function (_a) {
|
|
80
80
|
switch (_a.label) {
|
|
81
81
|
case 0:
|
|
@@ -89,7 +89,21 @@ var Server = /** @class */ (function () {
|
|
|
89
89
|
if (validationResp && validationResp instanceof Response_1.default)
|
|
90
90
|
return [2 /*return*/, validationResp];
|
|
91
91
|
}
|
|
92
|
+
// Validate query
|
|
93
|
+
if (route.querySchema) {
|
|
94
|
+
validationResp = Validator_1.default.validateSchema(request.getQueryParams(), route.querySchema);
|
|
95
|
+
if (validationResp && validationResp instanceof Response_1.default)
|
|
96
|
+
return [2 /*return*/, validationResp];
|
|
97
|
+
}
|
|
98
|
+
// parse before validating
|
|
92
99
|
this.parsePathParams(request, route.path);
|
|
100
|
+
// Validate path
|
|
101
|
+
if (route.pathSchema) {
|
|
102
|
+
console.log('VVVV', request.getPathParams());
|
|
103
|
+
validationResp = Validator_1.default.validateSchema(request.getPathParams(), route.pathSchema);
|
|
104
|
+
if (validationResp && validationResp instanceof Response_1.default)
|
|
105
|
+
return [2 /*return*/, validationResp];
|
|
106
|
+
}
|
|
93
107
|
return [4 /*yield*/, route.handler(transaction)];
|
|
94
108
|
case 1:
|
|
95
109
|
// Continue to route handler
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Server.js","sourceRoot":"","sources":["../../../../src/Server/lib/Server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iDAA6C;AAG7C,+CAAyC;AACzC,2DAAqD;AACrD,wDAAkD;AAElD,kDAA4C;AAE5C;;GAEG;AACH;IAcE;;;;OAIG;IACH,gBAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,aAAa,GAAG,IAAI,uBAAa,CAAC,MAAM,CAAC,CAAA;IAChD,CAAC;IAED;;;OAGG;IACI,0BAAS,GAAhB;QACE,OAAO,IAAI,CA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CAAC,MAAM,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC,CAAA;4CACtC,cAAc,GAAG,mBAAS,CAAC,cAAc,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,KAAK,CAAC,UAAU,CAAC,CAAA;4CAC1F,IAAI,cAAc,IAAI,cAAc,YAAY,kBAAQ;gDAAE,sBAAO,cAAc,EAAA;yCAChF;wCAGM,qBAAM,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAA;;oCADvC,4BAA4B;oCAC5B,sBAAO,SAAgC,EAAA;;oCAEzC,mBAAmB;oCACnB,sBAAO,IAAI,kBAAQ,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,kBAAkB,EAAE,CAAC,EAAA;;;6BACtD,CAAC,EAAA;;wBAnCF,mBAAmB;wBACnB,SAkCE,CAAA;;;;;KACH;IAED;;;;;OAKG;IACK,gCAAe,GAAvB,UAAwB,GAA2B,EAAE,SAAiB;QACpE,IAAM,IAAI,GAAG,GAAG,CAAC,OAAO,EAAE,CAAA;QAC1B,IAAM,IAAI,GAAG,EAAE,CAAA;QACf,IAAM,MAAM,GAAG,IAAA,6BAAY,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACvD,IAAI,MAAM;YAAE,GAAG,CAAC,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IAClD,CAAC;IACH,aAAC;AAAD,CAAC,AAzFD,IAyFC"}
|
|
@@ -104,9 +104,7 @@ var GenericHandlerEvent = /** @class */ (function () {
|
|
|
104
104
|
multiValueQueryStringParameters: (0, Utils_1.parseMultiValueQueryStringParameters)(this.request.url),
|
|
105
105
|
path: this.request.path,
|
|
106
106
|
pathParameters: null,
|
|
107
|
-
queryStringParameters: this.request.
|
|
108
|
-
? (0, Utils_1.parseQueryStringParameters)(this.request.query)
|
|
109
|
-
: null,
|
|
107
|
+
queryStringParameters: this.request.url ? (0, Utils_1.parseQueryStringParameters)(this.request.url) : null,
|
|
110
108
|
requestContext: {
|
|
111
109
|
accountId: process.env.AWS_ACCOUNT_ID || 'undefined',
|
|
112
110
|
apiId: '',
|