@creator.co/wapi 1.2.12 → 1.3.2-alpha
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 +1 -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/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 +1 -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/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/KnexTransaction.test.ts +1 -1
- package/tests/Server/lib/ContainerServer.test.ts +219 -1
- /package/src/Database/{types.d.ts → types.ts} +0 -0
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,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,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,MAAM,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAA;QAC3D,MAAM,CAAC,KAAK,CAAC,kBAAkB,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAA;IAC3D,CAAC;IAED;;;;OAIG;IACI,oCAAkB,GAAzB,UAA0B,SAAgC;QACxD,IAAM,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,CAAA;QACzC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,eAAK,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,eAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAA;IACxE,CAAC;IAED;;;;OAIG;IACI,+BAAa,GAApB,UAAqB,SAAgC;QACnD,OAAO,eAAK,CAAC,2BAA2B,CACtC,IAAI,CAAC,YAAY,CAAC,qBAA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AAA;QACjD,OAAO,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAA;IACxD,CAAC;IAED;;;;;OAKG;IACI,oCAAkB,GAAzB,UAA0B,IAAW,EAAE,MAAa;QAApD,iBAOC;QANC,IAAI,CAAC,YAAY,CAAC,cAAc,GAAG,EAAE,CAAA;QACrC,IAAI,CAAC,OAAO,CAAC,UAAC,GAAG,EAAE,KAAK;;YACtB,IAAI,MAAA,KAAI,CAAC,YAAY,0CAAE,cAAc,EAAE;gBACrC,KAAI,CAAC,YAAY,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAA;aAC/D;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IACH,cAAC;AAAD,CAAC,AAtLD,IAsLC;;AAED;;GAEG;AACH,IAAY,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.
|
|
@@ -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oB,CAAA,CAAA;IAClE,CAAC;IAED;;;OAGG;IACI,0BAAO,GAAd;QACE,OAAO,IAAI,CAAC,UAAU,CAAA;IACxB,CAAC;IAED;;;OAGG;IACI,0BAAO,GAAd;QACE,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;IAED;;;;;OAKG;IACI,iCAAc,GAArB,UAAsB,GAAW,EAAE,KAAU;QAC3C,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;IACxB,CAAC;IAED;;;;;OAKG;IACI,+BAAY,GAAnB,UAAoB,GAAW,EAAE,KAAU;QACzC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;IAC3B,CAAC;IAED;;;;;;OAMG;IACU,wBAAK,GAAlB,UACE,OAAgB,EAChB,
|
|
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,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,OAAO,GAAG;YACb,6BAA6B,EAAE,GAAG;YAClC,kCAAkC,EAAE,IAAI;YACxC,cAAc,EAAE,kBAAkB;SACnC,CAAA;QACD,YAAY;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O,IAAI,CAAA;IACb,CAAC;IAED;;;OAGG;IACW,iCAAwB,GAAtC;QACE,OAAO,IAAI,QAAQ,CAAO,GAAG,EAAE,IAAI,CAAC,CAAA;IACtC,CAAC;IAED;;;;;OAKG;IACW,8BAAqB,GAAnC,UAAoC,MAAW,EAAE,WAAmB;QAClE,IAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE;YACrC,YAAY,EAAE,IAAI;SACnB,CAAC,CAAA;QACF,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,YAAY,CAAC,CAAA;QAC7C,IAAI,WAAW;YAAE,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE,WAAW,CAAC,CAAA;QAC/D,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;;;OAKG;IACW,uBAAc,GAA5B,UACE,IAAc,EACd,YAAqB;QAErB,IAAM,IAAI,GAAG,IAAI,QAAQ,CAAW,YAAY,IAAI,GAAG,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, PathParamsType = StringMap, QueryParamsType = 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, PathParamsType, QueryParamsType>, 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,SAAS,CAAC,GAAC,CAAC,CAAA;;;;;;;;;;;;;;;;;wBAG5B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAA;wBAC9D,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAC,CAAC,KAAK,CAAC,CAAA;wBACxB,SAAS;wBACT,IAAI,IAAI,CAAC,YAAY;4BAAE,MAAM,GAAC,CAAA;;;;;;KAEjC;IAED;;;;;OAKG;IACW,wCAAkB,GAAhC,UAAiC,aAAa;;;;;;;wBAE1C,qBAAM,aAAa,EAAE,EAAA;;wBAArB,SAAqB,CAAA;;;;wBAErB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAA;wBAClD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAC,CAAC,CAAA;wBACxB,SAAS;wBACT,IAAI,IAAI,CAAC,YAAY;4BAAE,MAAM,GAAC,CAAA;;;wBAE9B,IAAI,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"}
|
|
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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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: '',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenericHandlerEvent.js","sourceRoot":"","sources":["../../../../../src/Server/lib/container/GenericHandlerEvent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2BAA4B;AAG5B,iCAA0F;AAC1F,4CAAsC;AAWtC;;GAEG;AACH;IAaE;;;;;OAKG;IACH,6BAAY,OAAgB,EAAE,iBAAkD;QAC9E,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAA;IAC5C,CAAC;IAED;;;OAGG;IACU,oCAAM,GAAnB;;;;gBACE,qDAAqD;gBACrD,sBAAO,IAAI,OAAO,CAAC,UAAO,OAAO,EAAE,MAAM;;;;;;oCAG/B,UAAQ,IAAI,CAAC,UAAU,EAAE,CAAA;oCACzB,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,OAAK,EAAE,UAAC,GAAoB,EAAE,IAAU;wCACxE,OAAO,CAAC,EAAE,GAAG,KAAA,EAAE,IAAI,MAAA,EAAE,CAAC,CAAA;oCACxB,CAAC,CAAC,CAAA;oCACF,SAAS;oCACT,qBAAM,IAAI,CAAC,iBAAiB,CAAC,OAAK,EAAE,OAAO,CAAC,EAAA;;oCAD5C,SAAS;oCACT,SAA4C,CAAA;;;;oCAE5C,MAAM,CAAC,GAAC,CAAC,CAAA,CAAC,oBAAoB;;;;;yBAEjC,CAAC,EAAA;;;KACH;IAED;;;OAGG;IACK,wCAAU,GAAlB;;QACE,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,IAAI;YAC/B,OAAO,EAAO,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;YAC1C,UAAU,EAAE,MAAA,IAAI,CAAC,OAAO,CAAC,MAAM,0CAAE,WAAW,EAAE;YAC9C,eAAe,EAAE,KAAK;YACtB,iBAAiB,EAAO,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;YACpD,+BAA+B,EAAE,IAAA,4CAAoC,EAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;YACvF,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;YACvB,cAAc,EAAE,IAAI;YACpB,qBAAqB,EAAE,IAAI,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"GenericHandlerEvent.js","sourceRoot":"","sources":["../../../../../src/Server/lib/container/GenericHandlerEvent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2BAA4B;AAG5B,iCAA0F;AAC1F,4CAAsC;AAWtC;;GAEG;AACH;IAaE;;;;;OAKG;IACH,6BAAY,OAAgB,EAAE,iBAAkD;QAC9E,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAA;IAC5C,CAAC;IAED;;;OAGG;IACU,oCAAM,GAAnB;;;;gBACE,qDAAqD;gBACrD,sBAAO,IAAI,OAAO,CAAC,UAAO,OAAO,EAAE,MAAM;;;;;;oCAG/B,UAAQ,IAAI,CAAC,UAAU,EAAE,CAAA;oCACzB,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,OAAK,EAAE,UAAC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AAY,GAApB,UACE,KAA2B,EAC3B,QAAoD;QAEpD,OAAO;YACL,YAAY,EAAE,KAAK,CAAC,cAAc,CAAC,SAAS;YAC5C,8BAA8B,EAAE,IAAI;YACpC,wBAAwB,EAAE;gBACxB,OAAO,CAAC,CAAA;YACV,CAAC;YACD,IAAI,EAAE,UAAC,GAAG,EAAE,IAAI,IAAK,OAAA,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,EAAnB,CAAmB;YACxC,IAAI,EAAE,UAAA,GAAG,IAAI,OAAA,QAAQ,CAAC,GAAG,CAAC,EAAb,CAAa;YAC1B,OAAO,EAAE,UAAA,GAAG,IAAI,OAAA,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,EAAxB,CAAwB;YACxC,YAAY,EAAE,oBAAoB;YAClC,eAAe,EAAE,QAAQ;YACzB,kBAAkB,EAAE,MAAM;YAC1B,eAAe,EAAE,IAAI;YACrB,YAAY,EAAE,WAAW;YACzB,aAAa,EAAE,WAAW;SAC3B,CAAA;IACH,CAAC;IACH,0BAAC;AAAD,CAAC,AAjID,IAiIC"}
|
package/index.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
|
|
|
@@ -44,4 +45,5 @@ export {
|
|
|
44
45
|
// Misc types
|
|
45
46
|
ResponseErrorType,
|
|
46
47
|
HttpMethod,
|
|
48
|
+
Database,
|
|
47
49
|
}
|
package/package.json
CHANGED
package/src/API/Request.ts
CHANGED
|
@@ -4,10 +4,13 @@ import Utils from './Utils'
|
|
|
4
4
|
import Logger from '../Logger/Logger'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Represents a request object with
|
|
8
|
-
* @
|
|
7
|
+
* Represents a request object with generic types for input, query parameters, and path parameters.
|
|
8
|
+
* @class Request
|
|
9
|
+
* @template InputType - The type of the input data for the request.
|
|
10
|
+
* @template PathParamsType - The type of the path parameters for the request.
|
|
11
|
+
* @template QueryParamsType - The type of the query parameters for the request.
|
|
9
12
|
*/
|
|
10
|
-
export default class Request<InputType> {
|
|
13
|
+
export default class Request<InputType, PathParamsType, QueryParamsType> {
|
|
11
14
|
/**
|
|
12
15
|
* Represents an API Gateway event for a request.
|
|
13
16
|
* @type {APIGatewayEvent}
|
|
@@ -33,22 +36,25 @@ export default class Request<InputType> {
|
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
/**
|
|
36
|
-
* Checks if the
|
|
37
|
-
* @param {
|
|
39
|
+
* Checks if the specified query parameter exists and has a valid value.
|
|
40
|
+
* @param {keyof QueryParamsType} paramName - The name of the query parameter to check.
|
|
38
41
|
* @returns {boolean} - True if the query parameter exists and has a valid value, false otherwise.
|
|
39
42
|
*/
|
|
40
|
-
public containsQueryParam(paramName:
|
|
43
|
+
public containsQueryParam(paramName: keyof QueryParamsType): boolean {
|
|
41
44
|
const val = this.getQueryParam(paramName)
|
|
42
45
|
return !!val && (Utils.isValidString(val) || Utils.isValidNumber(val))
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
/**
|
|
46
|
-
* Retrieves the value of a query parameter from the
|
|
47
|
-
* @param {
|
|
49
|
+
* Retrieves the value of a query parameter from the URL.
|
|
50
|
+
* @param {keyof QueryParamsType} paramName - The name of the query parameter to retrieve.
|
|
48
51
|
* @returns {string | null} The value of the query parameter, or null if it does not exist.
|
|
49
52
|
*/
|
|
50
|
-
public getQueryParam(paramName:
|
|
51
|
-
return Utils.caseInsensitiveObjectForKey(
|
|
53
|
+
public getQueryParam(paramName: keyof QueryParamsType): string | null {
|
|
54
|
+
return Utils.caseInsensitiveObjectForKey(
|
|
55
|
+
this.requestEvent.queryStringParameters,
|
|
56
|
+
String(paramName)
|
|
57
|
+
)
|
|
52
58
|
}
|
|
53
59
|
|
|
54
60
|
/**
|
|
@@ -70,22 +76,22 @@ export default class Request<InputType> {
|
|
|
70
76
|
}
|
|
71
77
|
|
|
72
78
|
/**
|
|
73
|
-
* Checks if the given parameter name exists in the
|
|
74
|
-
* @param {
|
|
75
|
-
* @returns {boolean} - True if the parameter exists
|
|
79
|
+
* Checks if the given parameter name exists in the PathParamsType object.
|
|
80
|
+
* @param {keyof PathParamsType} paramName - The name of the parameter to check.
|
|
81
|
+
* @returns {boolean} - True if the parameter exists, false otherwise.
|
|
76
82
|
*/
|
|
77
|
-
public containsPathParam(paramName:
|
|
83
|
+
public containsPathParam(paramName: keyof PathParamsType): boolean {
|
|
78
84
|
const val = this.getPathParam(paramName)
|
|
79
85
|
return !!val && (Utils.isValidString(val) || Utils.isValidNumber(val))
|
|
80
86
|
}
|
|
81
87
|
|
|
82
88
|
/**
|
|
83
|
-
* Retrieves the value of a path parameter from the
|
|
84
|
-
* @param {
|
|
89
|
+
* Retrieves the value of a specific path parameter from the URL.
|
|
90
|
+
* @param {keyof PathParamsType} paramName - The name of the path parameter to retrieve.
|
|
85
91
|
* @returns {string | null} The value of the path parameter, or null if it does not exist.
|
|
86
92
|
*/
|
|
87
|
-
public getPathParam(paramName:
|
|
88
|
-
return Utils.caseInsensitiveObjectForKey(this.requestEvent.pathParameters, paramName)
|
|
93
|
+
public getPathParam(paramName: keyof PathParamsType): string | null {
|
|
94
|
+
return Utils.caseInsensitiveObjectForKey(this.requestEvent.pathParameters, String(paramName))
|
|
89
95
|
}
|
|
90
96
|
|
|
91
97
|
/**
|
|
@@ -128,10 +134,21 @@ export default class Request<InputType> {
|
|
|
128
134
|
|
|
129
135
|
/**
|
|
130
136
|
* Retrieves the path parameters from the request event.
|
|
131
|
-
* @returns {
|
|
137
|
+
* @returns {PathParamsType | null} - The path parameters object, or null if not found.
|
|
132
138
|
*/
|
|
133
|
-
public getPathParams():
|
|
134
|
-
|
|
139
|
+
public getPathParams(): PathParamsType | null {
|
|
140
|
+
// type conversion guaranteed by validation
|
|
141
|
+
return this.requestEvent.pathParameters as PathParamsType
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Retrieves the query parameters from the request event.
|
|
146
|
+
* @returns {QueryParamsType | null} - The query parameters object, or null if not found.
|
|
147
|
+
*/
|
|
148
|
+
public getQueryParams(): QueryParamsType | null {
|
|
149
|
+
// type conversion guaranteed by validation
|
|
150
|
+
console.log(this.requestEvent.queryStringParameters)
|
|
151
|
+
return this.requestEvent.queryStringParameters as QueryParamsType
|
|
135
152
|
}
|
|
136
153
|
|
|
137
154
|
/**
|
package/src/API/Response.ts
CHANGED
|
@@ -161,7 +161,7 @@ export default class Response<BodyType = null> {
|
|
|
161
161
|
*/
|
|
162
162
|
public async build(
|
|
163
163
|
context: Context,
|
|
164
|
-
transaction: Transaction<any, any, any>,
|
|
164
|
+
transaction: Transaction<any, any, any, any, any>,
|
|
165
165
|
optDoNotCallContext: boolean
|
|
166
166
|
): Promise<void> {
|
|
167
167
|
//Stream support
|
|
@@ -17,6 +17,7 @@ import Publisher, { PublisherConfig } from '../Publisher/Publisher'
|
|
|
17
17
|
export type TransactionExecution<TransactionType, ResponseInnerType, MiscRespType = null> = (
|
|
18
18
|
transaction: TransactionType
|
|
19
19
|
) => Promise<Response<ResponseInnerType> | Response<ResponseErrorType> | MiscRespType>
|
|
20
|
+
|
|
20
21
|
/**
|
|
21
22
|
* Represents the configuration options for a transaction.
|
|
22
23
|
* @typedef {Object} TransactionConfig
|
|
@@ -33,6 +34,11 @@ export type TransactionConfig = {
|
|
|
33
34
|
publisher?: PublisherConfig
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Represents a simple string dictionary with string values
|
|
39
|
+
*/
|
|
40
|
+
export type StringMap = { [key: string]: string | null }
|
|
41
|
+
|
|
36
42
|
/**
|
|
37
43
|
* Represents a transaction object that handles the execution of a request and manages the response.
|
|
38
44
|
* @template InputType - The type of the input data for the transaction.
|
|
@@ -43,6 +49,8 @@ export default class Transaction<
|
|
|
43
49
|
InputType = object,
|
|
44
50
|
ResponseInnerType = null,
|
|
45
51
|
MiscRespType = null,
|
|
52
|
+
PathParamsType = StringMap,
|
|
53
|
+
QueryParamsType = StringMap,
|
|
46
54
|
> {
|
|
47
55
|
/**
|
|
48
56
|
* The instance of the DatabaseManager class used for managing the database.
|
|
@@ -87,7 +95,7 @@ export default class Transaction<
|
|
|
87
95
|
* The request object for making a request of type InputType.
|
|
88
96
|
* @readonly
|
|
89
97
|
*/
|
|
90
|
-
public readonly request: Request<InputType>
|
|
98
|
+
public readonly request: Request<InputType, PathParamsType, QueryParamsType>
|
|
91
99
|
/**
|
|
92
100
|
* The publisher of the content.
|
|
93
101
|
*/
|
|
@@ -123,7 +131,11 @@ export default class Transaction<
|
|
|
123
131
|
this.retrowErrors = !!config?.throwOnErrors /* retrow internal errors */
|
|
124
132
|
// components
|
|
125
133
|
this.logger = new Logger(config?.logger, transactionId)
|
|
126
|
-
this.request = new Request<InputType
|
|
134
|
+
this.request = new Request<InputType, PathParamsType, QueryParamsType>(
|
|
135
|
+
this.event,
|
|
136
|
+
this.context,
|
|
137
|
+
this.logger
|
|
138
|
+
)
|
|
127
139
|
this.publisher = new Publisher(config?.publisher)
|
|
128
140
|
}
|
|
129
141
|
|
|
@@ -135,7 +147,7 @@ export default class Transaction<
|
|
|
135
147
|
*/
|
|
136
148
|
public async execute(
|
|
137
149
|
executionFunc: TransactionExecution<
|
|
138
|
-
Transaction<InputType, ResponseInnerType, MiscRespType>,
|
|
150
|
+
Transaction<InputType, ResponseInnerType, MiscRespType, PathParamsType, QueryParamsType>,
|
|
139
151
|
ResponseInnerType,
|
|
140
152
|
MiscRespType
|
|
141
153
|
>
|
|
@@ -158,7 +170,7 @@ export default class Transaction<
|
|
|
158
170
|
*/
|
|
159
171
|
private async iexecute(
|
|
160
172
|
executionFunc: TransactionExecution<
|
|
161
|
-
Transaction<InputType, ResponseInnerType, MiscRespType>,
|
|
173
|
+
Transaction<InputType, ResponseInnerType, MiscRespType, PathParamsType, QueryParamsType>,
|
|
162
174
|
ResponseInnerType,
|
|
163
175
|
MiscRespType
|
|
164
176
|
>
|
package/src/Database/Database.ts
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
|
|
8
|
+
export {
|
|
9
|
+
DatabaseTransaction,
|
|
10
|
+
DbConfig,
|
|
11
|
+
KnexTransaction,
|
|
12
|
+
PostgresTransaction,
|
|
13
|
+
DatabaseManager,
|
|
14
|
+
Database,
|
|
15
|
+
}
|
package/src/Server/Router.ts
CHANGED
|
@@ -8,7 +8,11 @@ import Server from './lib/Server'
|
|
|
8
8
|
import { HttpMethod } from '../API/Request'
|
|
9
9
|
import { ResponseErrorType } from '../API/Response'
|
|
10
10
|
import Utils from '../API/Utils'
|
|
11
|
-
import Transaction, {
|
|
11
|
+
import Transaction, {
|
|
12
|
+
TransactionConfig,
|
|
13
|
+
TransactionExecution,
|
|
14
|
+
StringMap,
|
|
15
|
+
} from '../BaseEvent/Transaction'
|
|
12
16
|
|
|
13
17
|
/**
|
|
14
18
|
* Represents a route in an API.
|
|
@@ -19,7 +23,12 @@ import Transaction, { TransactionConfig, TransactionExecution } from '../BaseEve
|
|
|
19
23
|
* @property {TransactionExecution<Transaction<InputType, OutputType | ResponseErrorType>, OutputType | ResponseErrorType>} handler - The handler function for the route.
|
|
20
24
|
* @property {z.ZodObject<any>} [inputSchema] - The input schema for validating the input data.
|
|
21
25
|
*/
|
|
22
|
-
export interface Route<
|
|
26
|
+
export interface Route<
|
|
27
|
+
InputType = any,
|
|
28
|
+
OutputType = any,
|
|
29
|
+
PathParamsType = StringMap,
|
|
30
|
+
QueryParamsType = StringMap,
|
|
31
|
+
> {
|
|
23
32
|
/**
|
|
24
33
|
* Represents a file path as a string.
|
|
25
34
|
* @param {string} path - The file path.
|
|
@@ -39,24 +48,36 @@ export interface Route<InputType = any, OutputType = any> {
|
|
|
39
48
|
*/
|
|
40
49
|
/**
|
|
41
50
|
* Represents a handler for executing a transaction with the given input type and output type.
|
|
42
|
-
* @param {Transaction<InputType, OutputType | ResponseErrorType>} transaction - The transaction to execute.
|
|
51
|
+
* @param {Transaction<InputType, OutputType | ResponseErrorType, PathParamsType, QueryParamsType>} transaction - The transaction to execute.
|
|
43
52
|
* @param {OutputType | ResponseErrorType} - The output type or response error type of the transaction.
|
|
44
53
|
*/
|
|
45
54
|
handler: TransactionExecution<
|
|
46
|
-
Transaction<InputType, OutputType | ResponseErrorType>,
|
|
55
|
+
Transaction<InputType, OutputType | ResponseErrorType, null, PathParamsType, QueryParamsType>,
|
|
47
56
|
OutputType | ResponseErrorType
|
|
48
57
|
>
|
|
49
58
|
/**
|
|
50
|
-
<<<<<<< HEAD
|
|
51
59
|
* An optional input schema for validating the structure of the input data.
|
|
52
|
-
* @type {z.ZodObject<any>}
|
|
53
|
-
=======
|
|
54
60
|
* Description placeholder
|
|
55
61
|
*
|
|
56
62
|
* @type {?z.ZodObject<any> | z.ZodUnion<any>}
|
|
57
|
-
>>>>>>> 65ffb67 (Improve syntax with tighther eslint, fix lots of test errors, new proxy containerSetupHook and improved validation type)
|
|
58
63
|
*/
|
|
59
64
|
inputSchema?: z.ZodObject<any> | z.ZodUnion<any>
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* An optional input schema for validating the structure of the path params.
|
|
68
|
+
* Description placeholder
|
|
69
|
+
*
|
|
70
|
+
* @type {?z.ZodObject<any> | z.ZodUnion<any>}
|
|
71
|
+
*/
|
|
72
|
+
pathSchema?: z.ZodObject<any> | z.ZodUnion<any>
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* An optional input schema for validating the structure of the query params.
|
|
76
|
+
* Description placeholder
|
|
77
|
+
*
|
|
78
|
+
* @type {?z.ZodObject<any> | z.ZodUnion<any>}
|
|
79
|
+
*/
|
|
80
|
+
querySchema?: z.ZodObject<any> | z.ZodUnion<any>
|
|
60
81
|
}
|
|
61
82
|
|
|
62
83
|
/**
|
package/src/Server/lib/Server.ts
CHANGED
|
@@ -62,7 +62,24 @@ export default class Server {
|
|
|
62
62
|
if (validationResp && validationResp instanceof Response) return validationResp
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
// Validate query
|
|
66
|
+
if (route.querySchema) {
|
|
67
|
+
const validationResp = Validator.validateSchema(
|
|
68
|
+
request.getQueryParams(),
|
|
69
|
+
route.querySchema
|
|
70
|
+
)
|
|
71
|
+
if (validationResp && validationResp instanceof Response) return validationResp
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// parse before validating
|
|
65
75
|
this.parsePathParams(request, route.path)
|
|
76
|
+
// Validate path
|
|
77
|
+
if (route.pathSchema) {
|
|
78
|
+
console.log('VVVV', request.getPathParams())
|
|
79
|
+
const validationResp = Validator.validateSchema(request.getPathParams(), route.pathSchema)
|
|
80
|
+
if (validationResp && validationResp instanceof Response) return validationResp
|
|
81
|
+
}
|
|
82
|
+
|
|
66
83
|
// Continue to route handler
|
|
67
84
|
return await route.handler(transaction)
|
|
68
85
|
}
|
|
@@ -77,7 +94,7 @@ export default class Server {
|
|
|
77
94
|
* @param {string} routePath - The route path pattern to match against.
|
|
78
95
|
* @returns None
|
|
79
96
|
*/
|
|
80
|
-
private parsePathParams(req: Request<any>, routePath: string) {
|
|
97
|
+
private parsePathParams(req: Request<any, any, any>, routePath: string) {
|
|
81
98
|
const path = req.getPath()
|
|
82
99
|
const keys = []
|
|
83
100
|
const result = pathToRegexp(routePath, keys).exec(path)
|
|
@@ -76,9 +76,7 @@ export default class GenericHandlerEvent {
|
|
|
76
76
|
multiValueQueryStringParameters: parseMultiValueQueryStringParameters(this.request.url),
|
|
77
77
|
path: this.request.path,
|
|
78
78
|
pathParameters: null,
|
|
79
|
-
queryStringParameters: this.request.
|
|
80
|
-
? parseQueryStringParameters(this.request.query)
|
|
81
|
-
: null,
|
|
79
|
+
queryStringParameters: this.request.url ? parseQueryStringParameters(this.request.url) : null,
|
|
82
80
|
requestContext: {
|
|
83
81
|
accountId: process.env.AWS_ACCOUNT_ID || 'undefined',
|
|
84
82
|
apiId: '',
|
|
@@ -11,7 +11,11 @@ function newReq(event: any, context?: any) {
|
|
|
11
11
|
},
|
|
12
12
|
'123-456'
|
|
13
13
|
)
|
|
14
|
-
return new Request
|
|
14
|
+
return new Request<any, any, any>(
|
|
15
|
+
<APIGatewayEvent>(<unknown>event),
|
|
16
|
+
<Context>context ? context : {},
|
|
17
|
+
logger
|
|
18
|
+
)
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
describe('Request querystring', () => {
|
|
@@ -32,11 +36,13 @@ describe('Request querystring', () => {
|
|
|
32
36
|
})
|
|
33
37
|
|
|
34
38
|
test('Valid query string', () => {
|
|
39
|
+
const v = { '123': 'abc' }
|
|
35
40
|
const r = newReq({
|
|
36
|
-
queryStringParameters:
|
|
41
|
+
queryStringParameters: v,
|
|
37
42
|
})
|
|
38
43
|
expect(r.containsQueryParam('123')).to.be.true
|
|
39
44
|
expect(r.getQueryParam('123')).to.be.equals('abc')
|
|
45
|
+
expect(r.getQueryParams()).to.be.deep.equal(v)
|
|
40
46
|
})
|
|
41
47
|
|
|
42
48
|
test('Valid query string number', () => {
|
package/tests/API/Utils.test.ts
CHANGED
|
@@ -114,6 +114,16 @@ describe('isValidNumber', () => {
|
|
|
114
114
|
expect(v).to.be.false
|
|
115
115
|
})
|
|
116
116
|
|
|
117
|
+
test('Not a valid number if causes a crash on conversion', () => {
|
|
118
|
+
// @ts-ignore
|
|
119
|
+
const v = Utils.isValidNumber({
|
|
120
|
+
toString: () => {
|
|
121
|
+
throw new Error('Evil object')
|
|
122
|
+
},
|
|
123
|
+
})
|
|
124
|
+
expect(v).to.be.false
|
|
125
|
+
})
|
|
126
|
+
|
|
117
127
|
test('Valid number if numbers and chars after', () => {
|
|
118
128
|
const v = Utils.isValidNumber('123abc')
|
|
119
129
|
expect(v).to.be.true
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Knex } from 'knex'
|
|
2
2
|
|
|
3
|
+
import { DbConfig } from '../../../../src/Database'
|
|
3
4
|
import { KnexDatabase } from '../../../../src/Database/integrations/knex/KnexDatabase'
|
|
4
5
|
import { KnexTransactionImpl } from '../../../../src/Database/integrations/knex/KnexTransaction'
|
|
5
|
-
import type { DbConfig } from '../../../../src/Database/types'
|
|
6
6
|
|
|
7
7
|
const testResources = (config: Partial<DbConfig<'knex'>>) => {
|
|
8
8
|
const database = {
|
|
@@ -15,6 +15,17 @@ export const ViewSchema = z.object({
|
|
|
15
15
|
updatedAt: z.string(),
|
|
16
16
|
})
|
|
17
17
|
|
|
18
|
+
export const QuerySchema = z.object({
|
|
19
|
+
id: z.string(),
|
|
20
|
+
order: z.string().refine(
|
|
21
|
+
v => {
|
|
22
|
+
const n = Number(v)
|
|
23
|
+
return !isNaN(n) && v?.length > 0
|
|
24
|
+
},
|
|
25
|
+
{ message: 'Invalid number' }
|
|
26
|
+
),
|
|
27
|
+
})
|
|
28
|
+
|
|
18
29
|
describe('Container server routing', () => {
|
|
19
30
|
// @ts-ignore
|
|
20
31
|
let mockExit = jest.spyOn(process, 'exit').mockImplementation(() => {})
|
|
@@ -155,7 +166,7 @@ describe('Container server basics', () => {
|
|
|
155
166
|
}, 10000)
|
|
156
167
|
})
|
|
157
168
|
|
|
158
|
-
describe('Container server validation', () => {
|
|
169
|
+
describe('Container server validation (body)', () => {
|
|
159
170
|
// @ts-ignore
|
|
160
171
|
let mockExit = jest.spyOn(process, 'exit').mockImplementation(() => {})
|
|
161
172
|
beforeAll(() => {
|
|
@@ -324,4 +335,211 @@ describe('Container server validation', () => {
|
|
|
324
335
|
await server.stop()
|
|
325
336
|
})
|
|
326
337
|
})
|
|
338
|
+
|
|
339
|
+
describe('Container server validation (query)', () => {
|
|
340
|
+
// @ts-ignore
|
|
341
|
+
let mockExit = jest.spyOn(process, 'exit').mockImplementation(() => {})
|
|
342
|
+
beforeAll(() => {
|
|
343
|
+
// @ts-ignore
|
|
344
|
+
mockExit = jest.spyOn(process, 'exit').mockImplementation(() => {})
|
|
345
|
+
})
|
|
346
|
+
afterAll(() => {
|
|
347
|
+
mockExit.mockRestore()
|
|
348
|
+
})
|
|
349
|
+
beforeEach(() => {
|
|
350
|
+
mockExit.mockReset()
|
|
351
|
+
})
|
|
352
|
+
|
|
353
|
+
function validateValidationFailure(res: any, failureCount?: number) {
|
|
354
|
+
c_expect(res.body['err']).to.be.equals(Globals.ErrorResponseValidationFail)
|
|
355
|
+
c_expect(res.body['errCode']).to.be.equals(Globals.ErrorCode_InvalidInput)
|
|
356
|
+
c_expect(res.body['transactionID']).to.not.be.null
|
|
357
|
+
c_expect(res.body['transactionID']).to.be.an('string')
|
|
358
|
+
c_expect(res.body['validationFailure']?.length).to.be.equals(failureCount || 2)
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
test('Validates empty query', async () => {
|
|
362
|
+
const server = new ContainerServer({
|
|
363
|
+
routes: [
|
|
364
|
+
{
|
|
365
|
+
path: '/abc',
|
|
366
|
+
method: HttpMethod.POST,
|
|
367
|
+
querySchema: QuerySchema,
|
|
368
|
+
handler: async () => {
|
|
369
|
+
return Response.SimpleResponse({ name: 'abc' })
|
|
370
|
+
},
|
|
371
|
+
},
|
|
372
|
+
],
|
|
373
|
+
})
|
|
374
|
+
await server.start()
|
|
375
|
+
// Validation fails, empty body
|
|
376
|
+
const resG = await request(defaultUrl)
|
|
377
|
+
.post(`/abc`)
|
|
378
|
+
.expect('Content-Type', 'application/json; charset=utf-8')
|
|
379
|
+
.expect(400)
|
|
380
|
+
validateValidationFailure(resG, 1)
|
|
381
|
+
await server.stop()
|
|
382
|
+
})
|
|
383
|
+
|
|
384
|
+
test('Validates empty query differently', async () => {
|
|
385
|
+
const server = new ContainerServer({
|
|
386
|
+
routes: [
|
|
387
|
+
{
|
|
388
|
+
path: '/abc',
|
|
389
|
+
method: HttpMethod.POST,
|
|
390
|
+
querySchema: QuerySchema,
|
|
391
|
+
handler: async () => {
|
|
392
|
+
return Response.SimpleResponse({ name: 'abc' })
|
|
393
|
+
},
|
|
394
|
+
},
|
|
395
|
+
],
|
|
396
|
+
})
|
|
397
|
+
await server.start()
|
|
398
|
+
// Validation fails, empty body
|
|
399
|
+
const resG = await request(defaultUrl)
|
|
400
|
+
.post(`/abc?`)
|
|
401
|
+
.expect('Content-Type', 'application/json; charset=utf-8')
|
|
402
|
+
.expect(400)
|
|
403
|
+
validateValidationFailure(resG, 1)
|
|
404
|
+
await server.stop()
|
|
405
|
+
})
|
|
406
|
+
|
|
407
|
+
test('Validates missing props body', async () => {
|
|
408
|
+
const server = new ContainerServer({
|
|
409
|
+
routes: [
|
|
410
|
+
{
|
|
411
|
+
path: '/abc',
|
|
412
|
+
method: HttpMethod.POST,
|
|
413
|
+
querySchema: QuerySchema,
|
|
414
|
+
handler: async () => {
|
|
415
|
+
return Response.SimpleResponse({ name: 'abc' })
|
|
416
|
+
},
|
|
417
|
+
},
|
|
418
|
+
],
|
|
419
|
+
})
|
|
420
|
+
await server.start()
|
|
421
|
+
// Validation fails, empty body
|
|
422
|
+
const resG = await request(defaultUrl)
|
|
423
|
+
.post(`/abc?id=myname`)
|
|
424
|
+
.expect('Content-Type', 'application/json; charset=utf-8')
|
|
425
|
+
.expect(400)
|
|
426
|
+
validateValidationFailure(resG, 1)
|
|
427
|
+
await server.stop()
|
|
428
|
+
})
|
|
429
|
+
|
|
430
|
+
test('Validates wrong type props body', async () => {
|
|
431
|
+
const server = new ContainerServer({
|
|
432
|
+
routes: [
|
|
433
|
+
{
|
|
434
|
+
path: '/abc',
|
|
435
|
+
method: HttpMethod.POST,
|
|
436
|
+
querySchema: QuerySchema,
|
|
437
|
+
handler: async () => {
|
|
438
|
+
return Response.SimpleResponse({ name: 'abc' })
|
|
439
|
+
},
|
|
440
|
+
},
|
|
441
|
+
],
|
|
442
|
+
})
|
|
443
|
+
await server.start()
|
|
444
|
+
// Validation fails, empty body
|
|
445
|
+
const resG = await request(defaultUrl)
|
|
446
|
+
.post(`/abc?id=name&order=myname`)
|
|
447
|
+
.expect('Content-Type', 'application/json; charset=utf-8')
|
|
448
|
+
.expect(400)
|
|
449
|
+
validateValidationFailure(resG, 1)
|
|
450
|
+
await server.stop()
|
|
451
|
+
})
|
|
452
|
+
|
|
453
|
+
test('Validates successfully2', async () => {
|
|
454
|
+
const server = new ContainerServer({
|
|
455
|
+
routes: [
|
|
456
|
+
{
|
|
457
|
+
path: '/abc',
|
|
458
|
+
method: HttpMethod.POST,
|
|
459
|
+
querySchema: QuerySchema,
|
|
460
|
+
handler: async () => {
|
|
461
|
+
return Response.SimpleResponse({ name: 'abc' })
|
|
462
|
+
},
|
|
463
|
+
},
|
|
464
|
+
],
|
|
465
|
+
})
|
|
466
|
+
await server.start()
|
|
467
|
+
// Validation fails, empty body
|
|
468
|
+
await request(defaultUrl)
|
|
469
|
+
.post(`/abc`)
|
|
470
|
+
.query({ id: 'name', order: 123 })
|
|
471
|
+
.expect('Content-Type', 'application/json; charset=utf-8')
|
|
472
|
+
.expect(200)
|
|
473
|
+
await server.stop()
|
|
474
|
+
})
|
|
475
|
+
})
|
|
476
|
+
|
|
477
|
+
describe('Container server validation (path)', () => {
|
|
478
|
+
// @ts-ignore
|
|
479
|
+
let mockExit = jest.spyOn(process, 'exit').mockImplementation(() => {})
|
|
480
|
+
beforeAll(() => {
|
|
481
|
+
// @ts-ignore
|
|
482
|
+
mockExit = jest.spyOn(process, 'exit').mockImplementation(() => {})
|
|
483
|
+
})
|
|
484
|
+
afterAll(() => {
|
|
485
|
+
mockExit.mockRestore()
|
|
486
|
+
})
|
|
487
|
+
beforeEach(() => {
|
|
488
|
+
mockExit.mockReset()
|
|
489
|
+
})
|
|
490
|
+
|
|
491
|
+
function validateValidationFailure(res: any, failureCount?: number) {
|
|
492
|
+
c_expect(res.body['err']).to.be.equals(Globals.ErrorResponseValidationFail)
|
|
493
|
+
c_expect(res.body['errCode']).to.be.equals(Globals.ErrorCode_InvalidInput)
|
|
494
|
+
c_expect(res.body['transactionID']).to.not.be.null
|
|
495
|
+
c_expect(res.body['transactionID']).to.be.an('string')
|
|
496
|
+
c_expect(res.body['validationFailure']?.length).to.be.equals(failureCount || 2)
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
test('Validates wrong type props body', async () => {
|
|
500
|
+
const server = new ContainerServer({
|
|
501
|
+
routes: [
|
|
502
|
+
{
|
|
503
|
+
path: '/abc/:id/:order',
|
|
504
|
+
method: HttpMethod.POST,
|
|
505
|
+
pathSchema: QuerySchema,
|
|
506
|
+
handler: async () => {
|
|
507
|
+
return Response.SimpleResponse({ name: 'abc' })
|
|
508
|
+
},
|
|
509
|
+
},
|
|
510
|
+
],
|
|
511
|
+
})
|
|
512
|
+
await server.start()
|
|
513
|
+
// Validation fails, empty body
|
|
514
|
+
const resG = await request(defaultUrl)
|
|
515
|
+
.post(`/abc/name/myname`)
|
|
516
|
+
.expect('Content-Type', 'application/json; charset=utf-8')
|
|
517
|
+
.expect(400)
|
|
518
|
+
validateValidationFailure(resG, 1)
|
|
519
|
+
await server.stop()
|
|
520
|
+
})
|
|
521
|
+
|
|
522
|
+
test('Validates successfully4', async () => {
|
|
523
|
+
const server = new ContainerServer({
|
|
524
|
+
routes: [
|
|
525
|
+
{
|
|
526
|
+
path: '/abc/:id/:order',
|
|
527
|
+
method: HttpMethod.POST,
|
|
528
|
+
pathSchema: QuerySchema,
|
|
529
|
+
handler: async () => {
|
|
530
|
+
return Response.SimpleResponse({ name: 'abc' })
|
|
531
|
+
},
|
|
532
|
+
},
|
|
533
|
+
],
|
|
534
|
+
})
|
|
535
|
+
await server.start()
|
|
536
|
+
// Validation fails, empty body
|
|
537
|
+
await request(defaultUrl)
|
|
538
|
+
.post(`/abc/name/123`)
|
|
539
|
+
.expect('Content-Type', 'application/json; charset=utf-8')
|
|
540
|
+
.expect(200)
|
|
541
|
+
await server.stop()
|
|
542
|
+
})
|
|
543
|
+
})
|
|
544
|
+
|
|
327
545
|
export {}
|
|
File without changes
|