@creator.co/wapi 1.2.3 → 1.2.4
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/.github/workflows/npmpublish.yml +2 -5
- package/README.md +1 -3
- package/dist/index.d.ts +11 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/jest.config.d.ts +3 -0
- package/dist/jest.config.js +34 -0
- package/dist/jest.config.js.map +1 -0
- package/dist/package.json +64 -0
- package/dist/src/API/Request.d.ts +140 -0
- package/dist/src/API/Request.js +182 -0
- package/dist/src/API/Request.js.map +1 -0
- package/dist/src/API/Response.d.ts +256 -0
- package/dist/src/API/Response.js +398 -0
- package/dist/src/API/Response.js.map +1 -0
- package/dist/src/API/Utils.d.ts +63 -0
- package/dist/src/API/Utils.js +104 -0
- package/dist/src/API/Utils.js.map +1 -0
- package/dist/src/BaseEvent/EventProcessor.d.ts +81 -0
- package/dist/src/BaseEvent/EventProcessor.js +182 -0
- package/dist/src/BaseEvent/EventProcessor.js.map +1 -0
- package/dist/src/BaseEvent/Process.d.ts +74 -0
- package/dist/src/BaseEvent/Process.js +142 -0
- package/dist/src/BaseEvent/Process.js.map +1 -0
- package/dist/src/BaseEvent/Transaction.d.ts +29 -0
- package/dist/src/BaseEvent/Transaction.js +244 -0
- package/dist/src/BaseEvent/Transaction.js.map +1 -0
- package/dist/src/Config/Configuration.d.ts +131 -0
- package/dist/src/Config/Configuration.js +153 -0
- package/dist/src/Config/Configuration.js.map +1 -0
- package/dist/src/Config/EnvironmentVar.d.ts +101 -0
- package/dist/src/Config/EnvironmentVar.js +213 -0
- package/dist/src/Config/EnvironmentVar.js.map +1 -0
- package/dist/src/Crypto/Crypto.d.ts +57 -0
- package/dist/src/Crypto/Crypto.js +126 -0
- package/dist/src/Crypto/Crypto.js.map +1 -0
- package/dist/src/Crypto/JWT.d.ts +64 -0
- package/dist/src/Crypto/JWT.js +74 -0
- package/dist/src/Crypto/JWT.js.map +1 -0
- package/dist/src/Globals.d.ts +161 -0
- package/dist/src/Globals.js +173 -0
- package/dist/src/Globals.js.map +1 -0
- package/dist/src/Logger/Logger.d.ts +180 -0
- package/dist/src/Logger/Logger.js +412 -0
- package/dist/src/Logger/Logger.js.map +1 -0
- package/dist/src/Mailer/Mailer.d.ts +107 -0
- package/dist/src/Mailer/Mailer.js +313 -0
- package/dist/src/Mailer/Mailer.js.map +1 -0
- package/dist/src/Publisher/Publisher.d.ts +47 -0
- package/dist/src/Publisher/Publisher.js +141 -0
- package/dist/src/Publisher/Publisher.js.map +1 -0
- package/dist/src/Server/RouteResolver.d.ts +41 -0
- package/dist/src/Server/RouteResolver.js +135 -0
- package/dist/src/Server/RouteResolver.js.map +1 -0
- package/dist/src/Server/Router.d.ts +104 -0
- package/dist/src/Server/Router.js +45 -0
- package/dist/src/Server/Router.js.map +1 -0
- package/dist/src/Server/lib/ContainerServer.d.ts +58 -0
- package/dist/src/Server/lib/ContainerServer.js +143 -0
- package/dist/src/Server/lib/ContainerServer.js.map +1 -0
- package/dist/src/Server/lib/Server.d.ts +60 -0
- package/dist/src/Server/lib/Server.js +137 -0
- package/dist/src/Server/lib/Server.js.map +1 -0
- package/dist/src/Server/lib/container/GenericHandler.d.ts +4 -0
- package/dist/src/Server/lib/container/GenericHandler.js +138 -0
- package/dist/src/Server/lib/container/GenericHandler.js.map +1 -0
- package/dist/src/Server/lib/container/GenericHandlerEvent.d.ts +67 -0
- package/dist/src/Server/lib/container/GenericHandlerEvent.js +189 -0
- package/dist/src/Server/lib/container/GenericHandlerEvent.js.map +1 -0
- package/dist/src/Server/lib/container/HealthHandler.d.ts +3 -0
- package/dist/src/Server/lib/container/HealthHandler.js +45 -0
- package/dist/src/Server/lib/container/HealthHandler.js.map +1 -0
- package/dist/src/Server/lib/container/Proxy.d.ts +95 -0
- package/dist/src/Server/lib/container/Proxy.js +201 -0
- package/dist/src/Server/lib/container/Proxy.js.map +1 -0
- package/dist/src/Server/lib/container/Utils.d.ts +18 -0
- package/dist/src/Server/lib/container/Utils.js +84 -0
- package/dist/src/Server/lib/container/Utils.js.map +1 -0
- package/dist/src/Validation/Validator.d.ts +21 -0
- package/dist/src/Validation/Validator.js +48 -0
- package/dist/src/Validation/Validator.js.map +1 -0
- package/jest.config.ts +1 -8
- package/package.json +3 -3
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
name: NPM Publish
|
|
2
2
|
on:
|
|
3
3
|
push:
|
|
4
|
-
branches: [ "main" ]
|
|
4
|
+
branches: [ "main", "gabe/tweaks" ]
|
|
5
5
|
|
|
6
6
|
jobs:
|
|
7
7
|
Publish:
|
|
8
|
-
uses: Creator-co/tool-github-workflows/.github/workflows/
|
|
8
|
+
uses: Creator-co/tool-github-workflows/.github/workflows/npm-publish.yml@main2
|
|
9
9
|
secrets: inherit
|
|
10
10
|
with:
|
|
11
|
-
disablieSASTFailure: false
|
|
12
|
-
disableLintFailure: false
|
|
13
|
-
disableUTestFailure: false
|
|
14
11
|
NODE_VERSION: "16.x"
|
package/README.md
CHANGED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Response, { ResponseErrorType } from './src/API/Response';
|
|
2
|
+
import Utils from './src/API/Utils';
|
|
3
|
+
import EventProcessor from './src/BaseEvent/EventProcessor';
|
|
4
|
+
import Process from './src/BaseEvent/Process';
|
|
5
|
+
import Transaction from './src/BaseEvent/Transaction';
|
|
6
|
+
import Configuration from './src/Config/Configuration';
|
|
7
|
+
import Crypto from './src/Crypto/Crypto';
|
|
8
|
+
import JWT from './src/Crypto/JWT';
|
|
9
|
+
import Mailer from './src/Mailer/Mailer';
|
|
10
|
+
import Router, { Route } from './src/Server/Router';
|
|
11
|
+
export { Transaction, Process, EventProcessor, Router, Mailer, Crypto, JWT, Configuration, Response, Utils, Route, ResponseErrorType, };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Utils = exports.Response = exports.Configuration = exports.JWT = exports.Crypto = exports.Mailer = exports.Router = exports.EventProcessor = exports.Process = exports.Transaction = void 0;
|
|
4
|
+
var Response_1 = require("./src/API/Response");
|
|
5
|
+
exports.Response = Response_1.default;
|
|
6
|
+
var Utils_1 = require("./src/API/Utils");
|
|
7
|
+
exports.Utils = Utils_1.default;
|
|
8
|
+
var EventProcessor_1 = require("./src/BaseEvent/EventProcessor");
|
|
9
|
+
exports.EventProcessor = EventProcessor_1.default;
|
|
10
|
+
var Process_1 = require("./src/BaseEvent/Process");
|
|
11
|
+
exports.Process = Process_1.default;
|
|
12
|
+
var Transaction_1 = require("./src/BaseEvent/Transaction");
|
|
13
|
+
exports.Transaction = Transaction_1.default;
|
|
14
|
+
var Configuration_1 = require("./src/Config/Configuration");
|
|
15
|
+
exports.Configuration = Configuration_1.default;
|
|
16
|
+
var Crypto_1 = require("./src/Crypto/Crypto");
|
|
17
|
+
exports.Crypto = Crypto_1.default;
|
|
18
|
+
var JWT_1 = require("./src/Crypto/JWT");
|
|
19
|
+
exports.JWT = JWT_1.default;
|
|
20
|
+
var Mailer_1 = require("./src/Mailer/Mailer");
|
|
21
|
+
exports.Mailer = Mailer_1.default;
|
|
22
|
+
var Router_1 = require("./src/Server/Router");
|
|
23
|
+
exports.Router = Router_1.default;
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,+CAAgE;AAuB9D,mBAvBK,kBAAQ,CAuBL;AAtBV,yCAAmC;AAwBjC,gBAxBK,eAAK,CAwBL;AAvBP,iEAA2D;AAazD,yBAbK,wBAAc,CAaL;AAZhB,mDAA6C;AAW3C,kBAXK,iBAAO,CAWL;AAVT,2DAAqD;AASnD,sBATK,qBAAW,CASL;AARb,4DAAsD;AAgBpD,wBAhBK,uBAAa,CAgBL;AAff,8CAAwC;AAatC,iBAbK,gBAAM,CAaL;AAZR,wCAAkC;AAahC,cAbK,aAAG,CAaL;AAZL,8CAAwC;AAUtC,iBAVK,gBAAM,CAUL;AATR,8CAAmD;AAOjD,iBAPK,gBAAM,CAOL"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-env node */
|
|
4
|
+
var config = {
|
|
5
|
+
preset: 'ts-jest',
|
|
6
|
+
testEnvironment: 'node',
|
|
7
|
+
reporters: [
|
|
8
|
+
'default',
|
|
9
|
+
[
|
|
10
|
+
'jest-junit',
|
|
11
|
+
{
|
|
12
|
+
outputDirectory: 'coverage',
|
|
13
|
+
outputName: 'jest-junit.xml',
|
|
14
|
+
ancestorSeparator: ' › ',
|
|
15
|
+
uniqueOutputName: 'false',
|
|
16
|
+
suiteNameTemplate: '{filepath}',
|
|
17
|
+
classNameTemplate: '{classname}',
|
|
18
|
+
titleTemplate: '{title}',
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
],
|
|
22
|
+
coverageReporters: ['clover', 'json', 'lcov', ['text', { file: 'coverage.txt' }], 'json-summary'],
|
|
23
|
+
collectCoverageFrom: ['src/**/*.(t|j)s'],
|
|
24
|
+
coverageThreshold: {
|
|
25
|
+
global: {
|
|
26
|
+
branches: 80,
|
|
27
|
+
functions: 80,
|
|
28
|
+
lines: 80,
|
|
29
|
+
statements: 80,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
exports.default = config;
|
|
34
|
+
//# sourceMappingURL=jest.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest.config.js","sourceRoot":"","sources":["../jest.config.ts"],"names":[],"mappings":";;AACA,qBAAqB;AACrB,IAAM,MAAM,GAA0B;IACpC,MAAM,EAAE,SAAS;IACjB,eAAe,EAAE,MAAM;IACvB,SAAS,EAAE;QACT,SAAS;QACT;YACE,YAAY;YACZ;gBACE,eAAe,EAAE,UAAU;gBAC3B,UAAU,EAAE,gBAAgB;gBAC5B,iBAAiB,EAAE,KAAK;gBACxB,gBAAgB,EAAE,OAAO;gBACzB,iBAAiB,EAAE,YAAY;gBAC/B,iBAAiB,EAAE,aAAa;gBAChC,aAAa,EAAE,SAAS;aACzB;SACF;KACF;IACD,iBAAiB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,CAAC,EAAE,cAAc,CAAC;IACjG,mBAAmB,EAAE,CAAC,iBAAiB,CAAC;IACxC,iBAAiB,EAAE;QACjB,MAAM,EAAE;YACN,QAAQ,EAAE,EAAE;YACZ,SAAS,EAAE,EAAE;YACb,KAAK,EAAE,EAAE;YACT,UAAU,EAAE,EAAE;SACf;KACF;CACF,CAAA;AACD,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@creator.co/wapi",
|
|
3
|
+
"version": "1.2.4",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "npm run lint && tsc --build",
|
|
10
|
+
"clean": "tsc --build --clean",
|
|
11
|
+
"lint-fix": "eslint . --ext .ts --fix",
|
|
12
|
+
"lint": "eslint . --ext .ts",
|
|
13
|
+
"test": "jest --coverage --silent --runInBand && cat coverage/coverage.txt",
|
|
14
|
+
"test-dev": "jest --coverage --runInBand && cat coverage/coverage.txt"
|
|
15
|
+
},
|
|
16
|
+
"author": "",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@aws-sdk/client-kms": "^3.427.0",
|
|
20
|
+
"@aws-sdk/client-secrets-manager": "^3.427.0",
|
|
21
|
+
"@aws-sdk/client-ses": "^3.414.0",
|
|
22
|
+
"@aws-sdk/client-sns": "^3.398.0",
|
|
23
|
+
"@aws-sdk/client-ssm": "^3.427.0",
|
|
24
|
+
"@aws-sdk/credential-provider-node": "^3.414.0",
|
|
25
|
+
"@types/email-templates": "^10.0.1",
|
|
26
|
+
"@types/nodemailer": "^6.4.10",
|
|
27
|
+
"abind": "^1.0.5",
|
|
28
|
+
"cors": "^2.8.5",
|
|
29
|
+
"cuid": "^3.0.0",
|
|
30
|
+
"dotenv": "^16.3.1",
|
|
31
|
+
"email-templates": "^11.1.1",
|
|
32
|
+
"express": "^4.18.2",
|
|
33
|
+
"json-stringify-safe": "^5.0.1",
|
|
34
|
+
"jsonwebtoken": "^9.0.2",
|
|
35
|
+
"node-cache": "^5.1.2",
|
|
36
|
+
"parse-duration": "^1.1.0",
|
|
37
|
+
"sha1": "^1.1.1",
|
|
38
|
+
"stack-trace": "0.0.10",
|
|
39
|
+
"zod": "^3.22.4"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/aws-lambda": "^8.10.119",
|
|
43
|
+
"@types/express": "^4.17.19",
|
|
44
|
+
"@types/jest": "^29.5.6",
|
|
45
|
+
"@types/jsonwebtoken": "^9.0.3",
|
|
46
|
+
"@types/node": "^20.5.7",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^6.5.0",
|
|
48
|
+
"@typescript-eslint/parser": "^6.5.0",
|
|
49
|
+
"aws-lambda": "^1.0.7",
|
|
50
|
+
"aws-sdk-client-mock": "^3.0.0",
|
|
51
|
+
"chai": "^4.3.10",
|
|
52
|
+
"eslint": "^8.48.0",
|
|
53
|
+
"eslint-config-prettier": "^9.0.0",
|
|
54
|
+
"eslint-plugin-import": "^2.28.1",
|
|
55
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
56
|
+
"jest": "^29.7.0",
|
|
57
|
+
"jest-junit": "^16.0.0",
|
|
58
|
+
"prettier": "^3.0.3",
|
|
59
|
+
"supertest": "^6.3.3",
|
|
60
|
+
"ts-jest": "^29.1.1",
|
|
61
|
+
"ts-node": "^10.9.1",
|
|
62
|
+
"typescript": "^5.2.2"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { Context, APIGatewayEvent } from 'aws-lambda';
|
|
2
|
+
import Logger from '../Logger/Logger';
|
|
3
|
+
/**
|
|
4
|
+
* ${1:Description placeholder}
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @class Request
|
|
8
|
+
* @typedef {Request}
|
|
9
|
+
* @template InputType
|
|
10
|
+
*/
|
|
11
|
+
export default class Request<InputType> {
|
|
12
|
+
/**
|
|
13
|
+
* ${1:Description placeholder}
|
|
14
|
+
*
|
|
15
|
+
* @private
|
|
16
|
+
* @type {APIGatewayEvent}
|
|
17
|
+
*/
|
|
18
|
+
private requestEvent;
|
|
19
|
+
/**
|
|
20
|
+
* ${1:Description placeholder}
|
|
21
|
+
*
|
|
22
|
+
* @private
|
|
23
|
+
* @type {Context}
|
|
24
|
+
*/
|
|
25
|
+
private context;
|
|
26
|
+
/**
|
|
27
|
+
* Creates an instance of Request.
|
|
28
|
+
*
|
|
29
|
+
* @constructor
|
|
30
|
+
* @param {APIGatewayEvent} requestEvent
|
|
31
|
+
* @param {Context} context
|
|
32
|
+
* @param {Logger} logger
|
|
33
|
+
*/
|
|
34
|
+
constructor(requestEvent: APIGatewayEvent, context: Context, logger: Logger);
|
|
35
|
+
/**
|
|
36
|
+
* ${1:Description placeholder}
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
39
|
+
* @param {string} paramName
|
|
40
|
+
* @returns {boolean}
|
|
41
|
+
*/
|
|
42
|
+
containsQueryParam(paramName: string): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* ${1:Description placeholder}
|
|
45
|
+
*
|
|
46
|
+
* @public
|
|
47
|
+
* @param {string} paramName
|
|
48
|
+
* @returns {(string | null)}
|
|
49
|
+
*/
|
|
50
|
+
getQueryParam(paramName: string): string | null;
|
|
51
|
+
/**
|
|
52
|
+
* ${1:Description placeholder}
|
|
53
|
+
*
|
|
54
|
+
* @public
|
|
55
|
+
* @param {string} headerName
|
|
56
|
+
* @returns {(string | null)}
|
|
57
|
+
*/
|
|
58
|
+
getHeader(headerName: string): string | null;
|
|
59
|
+
/**
|
|
60
|
+
* ${1:Description placeholder}
|
|
61
|
+
*
|
|
62
|
+
* @public
|
|
63
|
+
* @param {string} cxtParam
|
|
64
|
+
* @returns {(any | null)}
|
|
65
|
+
*/
|
|
66
|
+
getContextParam(cxtParam: string): any | null;
|
|
67
|
+
/**
|
|
68
|
+
* ${1:Description placeholder}
|
|
69
|
+
*
|
|
70
|
+
* @public
|
|
71
|
+
* @param {string} paramName
|
|
72
|
+
* @returns {boolean}
|
|
73
|
+
*/
|
|
74
|
+
containsPathParam(paramName: string): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* ${1:Description placeholder}
|
|
77
|
+
*
|
|
78
|
+
* @public
|
|
79
|
+
* @param {string} paramName
|
|
80
|
+
* @returns {(string | null)}
|
|
81
|
+
*/
|
|
82
|
+
getPathParam(paramName: string): string | null;
|
|
83
|
+
/**
|
|
84
|
+
* ${1:Description placeholder}
|
|
85
|
+
*
|
|
86
|
+
* @public
|
|
87
|
+
* @returns {InputType}
|
|
88
|
+
*/
|
|
89
|
+
getBody(): InputType;
|
|
90
|
+
/**
|
|
91
|
+
* ${1:Description placeholder}
|
|
92
|
+
*
|
|
93
|
+
* @public
|
|
94
|
+
* @returns {string}
|
|
95
|
+
*/
|
|
96
|
+
getPath(): string;
|
|
97
|
+
/**
|
|
98
|
+
* ${1:Description placeholder}
|
|
99
|
+
*
|
|
100
|
+
* @public
|
|
101
|
+
* @returns {string}
|
|
102
|
+
*/
|
|
103
|
+
getMethod(): string;
|
|
104
|
+
/**
|
|
105
|
+
* ${1:Description placeholder}
|
|
106
|
+
*
|
|
107
|
+
* @public
|
|
108
|
+
* @returns {(object | null)}
|
|
109
|
+
*/
|
|
110
|
+
getPathParams(): object | null;
|
|
111
|
+
/**
|
|
112
|
+
* ${1:Description placeholder}
|
|
113
|
+
*
|
|
114
|
+
* @public
|
|
115
|
+
* @returns {(string | null)}
|
|
116
|
+
*/
|
|
117
|
+
getAuthorizationHeader(): string | null;
|
|
118
|
+
/**
|
|
119
|
+
* ${1:Description placeholder}
|
|
120
|
+
*
|
|
121
|
+
* @public
|
|
122
|
+
* @returns {string}
|
|
123
|
+
*/
|
|
124
|
+
getRequestID(): string;
|
|
125
|
+
/**
|
|
126
|
+
* ${1:Description placeholder}
|
|
127
|
+
*
|
|
128
|
+
* @public
|
|
129
|
+
* @returns {string}
|
|
130
|
+
*/
|
|
131
|
+
getOriginIP(): string;
|
|
132
|
+
/**
|
|
133
|
+
* ${1:Description placeholder}
|
|
134
|
+
*
|
|
135
|
+
* @public
|
|
136
|
+
* @param {any[]} keys
|
|
137
|
+
* @param {any[]} result
|
|
138
|
+
*/
|
|
139
|
+
setFixedPathParams(keys: any[], result: any[]): void;
|
|
140
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var Utils_1 = require("./Utils");
|
|
4
|
+
/**
|
|
5
|
+
* ${1:Description placeholder}
|
|
6
|
+
*
|
|
7
|
+
* @export
|
|
8
|
+
* @class Request
|
|
9
|
+
* @typedef {Request}
|
|
10
|
+
* @template InputType
|
|
11
|
+
*/
|
|
12
|
+
var Request = /** @class */ (function () {
|
|
13
|
+
/**
|
|
14
|
+
* Creates an instance of Request.
|
|
15
|
+
*
|
|
16
|
+
* @constructor
|
|
17
|
+
* @param {APIGatewayEvent} requestEvent
|
|
18
|
+
* @param {Context} context
|
|
19
|
+
* @param {Logger} logger
|
|
20
|
+
*/
|
|
21
|
+
function Request(requestEvent, context, logger) {
|
|
22
|
+
this.requestEvent = requestEvent;
|
|
23
|
+
this.context = context;
|
|
24
|
+
logger.debug('Request info:', JSON.stringify(requestEvent));
|
|
25
|
+
logger.debug('Request context:', JSON.stringify(context));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* ${1:Description placeholder}
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
* @param {string} paramName
|
|
32
|
+
* @returns {boolean}
|
|
33
|
+
*/
|
|
34
|
+
Request.prototype.containsQueryParam = function (paramName) {
|
|
35
|
+
var val = this.getQueryParam(paramName);
|
|
36
|
+
return !!val && (Utils_1.default.isValidString(val) || Utils_1.default.isValidNumber(val));
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* ${1:Description placeholder}
|
|
40
|
+
*
|
|
41
|
+
* @public
|
|
42
|
+
* @param {string} paramName
|
|
43
|
+
* @returns {(string | null)}
|
|
44
|
+
*/
|
|
45
|
+
Request.prototype.getQueryParam = function (paramName) {
|
|
46
|
+
return Utils_1.default.caseInsensitiveObjectForKey(this.requestEvent.queryStringParameters, paramName);
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* ${1:Description placeholder}
|
|
50
|
+
*
|
|
51
|
+
* @public
|
|
52
|
+
* @param {string} headerName
|
|
53
|
+
* @returns {(string | null)}
|
|
54
|
+
*/
|
|
55
|
+
Request.prototype.getHeader = function (headerName) {
|
|
56
|
+
return Utils_1.default.caseInsensitiveObjectForKey(this.requestEvent.headers, headerName);
|
|
57
|
+
};
|
|
58
|
+
//context params
|
|
59
|
+
/**
|
|
60
|
+
* ${1:Description placeholder}
|
|
61
|
+
*
|
|
62
|
+
* @public
|
|
63
|
+
* @param {string} cxtParam
|
|
64
|
+
* @returns {(any | null)}
|
|
65
|
+
*/
|
|
66
|
+
Request.prototype.getContextParam = function (cxtParam) {
|
|
67
|
+
return Utils_1.default.caseInsensitiveObjectForKey(this.requestEvent.requestContext, cxtParam);
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* ${1:Description placeholder}
|
|
71
|
+
*
|
|
72
|
+
* @public
|
|
73
|
+
* @param {string} paramName
|
|
74
|
+
* @returns {boolean}
|
|
75
|
+
*/
|
|
76
|
+
Request.prototype.containsPathParam = function (paramName) {
|
|
77
|
+
var val = this.getPathParam(paramName);
|
|
78
|
+
return !!val && (Utils_1.default.isValidString(val) || Utils_1.default.isValidNumber(val));
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* ${1:Description placeholder}
|
|
82
|
+
*
|
|
83
|
+
* @public
|
|
84
|
+
* @param {string} paramName
|
|
85
|
+
* @returns {(string | null)}
|
|
86
|
+
*/
|
|
87
|
+
Request.prototype.getPathParam = function (paramName) {
|
|
88
|
+
return Utils_1.default.caseInsensitiveObjectForKey(this.requestEvent.pathParameters, paramName);
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* ${1:Description placeholder}
|
|
92
|
+
*
|
|
93
|
+
* @public
|
|
94
|
+
* @returns {InputType}
|
|
95
|
+
*/
|
|
96
|
+
Request.prototype.getBody = function () {
|
|
97
|
+
var b = null;
|
|
98
|
+
try {
|
|
99
|
+
b = this.requestEvent.body;
|
|
100
|
+
if (typeof b === 'string' || b instanceof String)
|
|
101
|
+
b = JSON.parse(b);
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
console.error('Error while getting request body!', e);
|
|
105
|
+
}
|
|
106
|
+
return b;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* ${1:Description placeholder}
|
|
110
|
+
*
|
|
111
|
+
* @public
|
|
112
|
+
* @returns {string}
|
|
113
|
+
*/
|
|
114
|
+
Request.prototype.getPath = function () {
|
|
115
|
+
return this.requestEvent.path;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* ${1:Description placeholder}
|
|
119
|
+
*
|
|
120
|
+
* @public
|
|
121
|
+
* @returns {string}
|
|
122
|
+
*/
|
|
123
|
+
Request.prototype.getMethod = function () {
|
|
124
|
+
return this.requestEvent.httpMethod;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* ${1:Description placeholder}
|
|
128
|
+
*
|
|
129
|
+
* @public
|
|
130
|
+
* @returns {(object | null)}
|
|
131
|
+
*/
|
|
132
|
+
Request.prototype.getPathParams = function () {
|
|
133
|
+
return this.requestEvent.pathParameters;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* ${1:Description placeholder}
|
|
137
|
+
*
|
|
138
|
+
* @public
|
|
139
|
+
* @returns {(string | null)}
|
|
140
|
+
*/
|
|
141
|
+
Request.prototype.getAuthorizationHeader = function () {
|
|
142
|
+
return this.getHeader('Authorization');
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* ${1:Description placeholder}
|
|
146
|
+
*
|
|
147
|
+
* @public
|
|
148
|
+
* @returns {string}
|
|
149
|
+
*/
|
|
150
|
+
Request.prototype.getRequestID = function () {
|
|
151
|
+
if (this.context.awsRequestId)
|
|
152
|
+
return this.context.awsRequestId;
|
|
153
|
+
return this.requestEvent.requestContext ? this.requestEvent.requestContext.requestId : 'unknown';
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* ${1:Description placeholder}
|
|
157
|
+
*
|
|
158
|
+
* @public
|
|
159
|
+
* @returns {string}
|
|
160
|
+
*/
|
|
161
|
+
Request.prototype.getOriginIP = function () {
|
|
162
|
+
var _a;
|
|
163
|
+
var origin = (_a = this.getContextParam('identity')) === null || _a === void 0 ? void 0 : _a.sourceIp;
|
|
164
|
+
var hOrigin = this.getHeader('X-Forwarded-For');
|
|
165
|
+
return origin ? origin : hOrigin ? hOrigin : 'unknown';
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* ${1:Description placeholder}
|
|
169
|
+
*
|
|
170
|
+
* @public
|
|
171
|
+
* @param {any[]} keys
|
|
172
|
+
* @param {any[]} result
|
|
173
|
+
*/
|
|
174
|
+
Request.prototype.setFixedPathParams = function (keys, result) {
|
|
175
|
+
var _this = this;
|
|
176
|
+
this.requestEvent.pathParameters = {};
|
|
177
|
+
keys.forEach(function (key, index) { return (_this.requestEvent.pathParameters[key.name] = result[index + 1]); });
|
|
178
|
+
};
|
|
179
|
+
return Request;
|
|
180
|
+
}());
|
|
181
|
+
exports.default = Request;
|
|
182
|
+
//# sourceMappingURL=Request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Request.js","sourceRoot":"","sources":["../../../src/API/Request.ts"],"names":[],"mappings":";;AAEA,iCAA2B;AAE3B;;;;;;;GAOG;AACH;IAeE;;;;;;;OAOG;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;IACD;;;;;;OAMG;IACI,oCAAkB,GAAzB,UAA0B,SAAiB;QACzC,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;IACD;;;;;;OAMG;IACI,+BAAa,GAApB,UAAqB,SAAiB;QACpC,OAAO,eAAK,CAAC,2BAA2B,CAAC,IAAI,CAAC,YAAY,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAA;IAC9F,CAAC;IACD;;;;;;OAMG;IACI,2BAAS,GAAhB,UAAiB,UAAkB;QACjC,OAAO,eAAK,CAAC,2BAA2B,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,UAAU,CAAC,CAAA;IACjF,CAAC;IACD,gBAAgB;IAChB;;;;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