@jaypie/express 1.0.15 → 1.1.0
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/LICENSE.txt +21 -0
- package/README.md +2 -10
- package/dist/module.cjs +7 -9
- package/dist/module.esm.js +7 -9
- package/package.json +8 -28
- package/src/decorateResponse.helper.js +6 -6
- package/src/expressHandler.js +1 -3
- package/.eslintignore +0 -1
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Finlayson Studio, LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -2,15 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Express Jaypie handler for AWS Lambda
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
### Installation
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install @jaypie/express
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
See [Jaypie documentation](https://github.com/finlaysonstudio/jaypie) for usage.
|
|
5
|
+
See [Jaypie](https://github.com/finlaysonstudio/jaypie) for usage.
|
|
14
6
|
|
|
15
7
|
## 📝 Changelog
|
|
16
8
|
|
|
@@ -22,4 +14,4 @@ See [Jaypie documentation](https://github.com/finlaysonstudio/jaypie) for usage.
|
|
|
22
14
|
|
|
23
15
|
## 📜 License
|
|
24
16
|
|
|
25
|
-
Published by Finlayson Studio
|
|
17
|
+
[MIT License](./LICENSE.txt). Published by Finlayson Studio
|
package/dist/module.cjs
CHANGED
|
@@ -60,7 +60,7 @@ const decorateResponse = (
|
|
|
60
60
|
//
|
|
61
61
|
if (typeof res !== "object" || res === null) {
|
|
62
62
|
log.warn("decorateResponse called but response is not an object");
|
|
63
|
-
return;
|
|
63
|
+
return;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
try {
|
|
@@ -79,28 +79,28 @@ const decorateResponse = (
|
|
|
79
79
|
|
|
80
80
|
// X-Project-Environment
|
|
81
81
|
if (process.env.PROJECT_ENV) {
|
|
82
|
-
res.
|
|
82
|
+
res.set(core.HTTP.HEADER.PROJECT.ENVIRONMENT, process.env.PROJECT_ENV);
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
// X-Project-Handler
|
|
86
86
|
if (handler) {
|
|
87
|
-
res.
|
|
87
|
+
res.set(core.HTTP.HEADER.PROJECT.HANDLER, handler);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
// X-Project-Invocation
|
|
91
91
|
const currentInvoke = getCurrentInvokeUuid();
|
|
92
92
|
if (currentInvoke) {
|
|
93
|
-
res.
|
|
93
|
+
res.set(core.HTTP.HEADER.PROJECT.INVOCATION, currentInvoke);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
// X-Project-Key
|
|
97
97
|
if (process.env.PROJECT_KEY) {
|
|
98
|
-
res.
|
|
98
|
+
res.set(core.HTTP.HEADER.PROJECT.KEY, process.env.PROJECT_KEY);
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
// X-Project-Version
|
|
102
102
|
if (version) {
|
|
103
|
-
res.
|
|
103
|
+
res.set(core.HTTP.HEADER.PROJECT.VERSION, version);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
//
|
|
@@ -180,7 +180,6 @@ const expressHandler = (handler, options = {}) => {
|
|
|
180
180
|
//
|
|
181
181
|
// Validate
|
|
182
182
|
//
|
|
183
|
-
/* eslint-disable no-autofix/prefer-const */
|
|
184
183
|
let {
|
|
185
184
|
locals,
|
|
186
185
|
name,
|
|
@@ -189,7 +188,6 @@ const expressHandler = (handler, options = {}) => {
|
|
|
189
188
|
unavailable,
|
|
190
189
|
validate,
|
|
191
190
|
} = options;
|
|
192
|
-
/* eslint-enable no-autofix/prefer-const */
|
|
193
191
|
core.validate.function(handler);
|
|
194
192
|
core.validate.optional.object(locals);
|
|
195
193
|
setup = core.force.array(setup); // allows a single item
|
|
@@ -305,7 +303,6 @@ const expressHandler = (handler, options = {}) => {
|
|
|
305
303
|
const key = keys[i];
|
|
306
304
|
libLogger.trace(`[jaypie] Locals: ${key}`);
|
|
307
305
|
if (typeof locals[key] === "function") {
|
|
308
|
-
// eslint-disable-next-line no-await-in-loop
|
|
309
306
|
localsReq.locals[key] = await locals[key](localsReq, localsRes);
|
|
310
307
|
} else {
|
|
311
308
|
localsReq.locals[key] = locals[key];
|
|
@@ -392,6 +389,7 @@ const expressHandler = (handler, options = {}) => {
|
|
|
392
389
|
} else if (typeof response === "string") {
|
|
393
390
|
try {
|
|
394
391
|
res.status(status).json(JSON.parse(response));
|
|
392
|
+
// eslint-disable-next-line no-unused-vars
|
|
395
393
|
} catch (error) {
|
|
396
394
|
res.status(status).send(response);
|
|
397
395
|
}
|
package/dist/module.esm.js
CHANGED
|
@@ -58,7 +58,7 @@ const decorateResponse = (
|
|
|
58
58
|
//
|
|
59
59
|
if (typeof res !== "object" || res === null) {
|
|
60
60
|
log$1.warn("decorateResponse called but response is not an object");
|
|
61
|
-
return;
|
|
61
|
+
return;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
try {
|
|
@@ -77,28 +77,28 @@ const decorateResponse = (
|
|
|
77
77
|
|
|
78
78
|
// X-Project-Environment
|
|
79
79
|
if (process.env.PROJECT_ENV) {
|
|
80
|
-
res.
|
|
80
|
+
res.set(HTTP.HEADER.PROJECT.ENVIRONMENT, process.env.PROJECT_ENV);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
// X-Project-Handler
|
|
84
84
|
if (handler) {
|
|
85
|
-
res.
|
|
85
|
+
res.set(HTTP.HEADER.PROJECT.HANDLER, handler);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
// X-Project-Invocation
|
|
89
89
|
const currentInvoke = getCurrentInvokeUuid();
|
|
90
90
|
if (currentInvoke) {
|
|
91
|
-
res.
|
|
91
|
+
res.set(HTTP.HEADER.PROJECT.INVOCATION, currentInvoke);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
// X-Project-Key
|
|
95
95
|
if (process.env.PROJECT_KEY) {
|
|
96
|
-
res.
|
|
96
|
+
res.set(HTTP.HEADER.PROJECT.KEY, process.env.PROJECT_KEY);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
// X-Project-Version
|
|
100
100
|
if (version) {
|
|
101
|
-
res.
|
|
101
|
+
res.set(HTTP.HEADER.PROJECT.VERSION, version);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
//
|
|
@@ -178,7 +178,6 @@ const expressHandler = (handler, options = {}) => {
|
|
|
178
178
|
//
|
|
179
179
|
// Validate
|
|
180
180
|
//
|
|
181
|
-
/* eslint-disable no-autofix/prefer-const */
|
|
182
181
|
let {
|
|
183
182
|
locals,
|
|
184
183
|
name,
|
|
@@ -187,7 +186,6 @@ const expressHandler = (handler, options = {}) => {
|
|
|
187
186
|
unavailable,
|
|
188
187
|
validate: validate$1,
|
|
189
188
|
} = options;
|
|
190
|
-
/* eslint-enable no-autofix/prefer-const */
|
|
191
189
|
validate.function(handler);
|
|
192
190
|
validate.optional.object(locals);
|
|
193
191
|
setup = force.array(setup); // allows a single item
|
|
@@ -303,7 +301,6 @@ const expressHandler = (handler, options = {}) => {
|
|
|
303
301
|
const key = keys[i];
|
|
304
302
|
libLogger.trace(`[jaypie] Locals: ${key}`);
|
|
305
303
|
if (typeof locals[key] === "function") {
|
|
306
|
-
// eslint-disable-next-line no-await-in-loop
|
|
307
304
|
localsReq.locals[key] = await locals[key](localsReq, localsRes);
|
|
308
305
|
} else {
|
|
309
306
|
localsReq.locals[key] = locals[key];
|
|
@@ -390,6 +387,7 @@ const expressHandler = (handler, options = {}) => {
|
|
|
390
387
|
} else if (typeof response === "string") {
|
|
391
388
|
try {
|
|
392
389
|
res.status(status).json(JSON.parse(response));
|
|
390
|
+
// eslint-disable-next-line no-unused-vars
|
|
393
391
|
} catch (error) {
|
|
394
392
|
res.status(status).send(response);
|
|
395
393
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jaypie/express",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"license": "MIT",
|
|
4
5
|
"author": "Finlayson Studio",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"exports": {
|
|
@@ -17,17 +18,9 @@
|
|
|
17
18
|
"format": "npm run format:package && npm run format:lint",
|
|
18
19
|
"format:lint": "eslint --fix .",
|
|
19
20
|
"format:package": "sort-package-json ./package.json",
|
|
20
|
-
"init:deploy": "hygen jaypie workflow-npm",
|
|
21
21
|
"lint": "eslint .",
|
|
22
|
-
"new": "hygen jaypie vite",
|
|
23
|
-
"new:command": "hygen jaypie command",
|
|
24
|
-
"new:constants": "hygen jaypie constants",
|
|
25
|
-
"new:hygen": "hygen jaypie hygen",
|
|
26
|
-
"new:index": "hygen jaypie index",
|
|
27
|
-
"new:model": "hygen jaypie model",
|
|
28
|
-
"new:test": "hygen jaypie vitest",
|
|
29
22
|
"prepublish": "npm run build",
|
|
30
|
-
"test": "vitest",
|
|
23
|
+
"test": "vitest run .",
|
|
31
24
|
"test:spec:constants": "vitest run ./src/__tests__/constants.spec.js",
|
|
32
25
|
"test:spec:decorateResponse.helper": "vitest run ./src/__tests__/decorateResponse.helper.spec.js",
|
|
33
26
|
"test:spec:echo.handler": "vitest run ./src/__tests__/echo.handler.spec.js",
|
|
@@ -42,23 +35,10 @@
|
|
|
42
35
|
},
|
|
43
36
|
"dependencies": {
|
|
44
37
|
"@codegenie/serverless-express": "^4.15.0",
|
|
45
|
-
"@jaypie/core": "^1.0
|
|
38
|
+
"@jaypie/core": "^1.1.0"
|
|
46
39
|
},
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"eslint": "^8.57.0",
|
|
52
|
-
"eslint-config-jaypie": "^1.0.7",
|
|
53
|
-
"express": "^4.19.2",
|
|
54
|
-
"hygen": "^6.2.11",
|
|
55
|
-
"jest-extended": "^4.0.2",
|
|
56
|
-
"mock-express-response": "^0.3.0",
|
|
57
|
-
"prettier": "^3.2.5",
|
|
58
|
-
"rollup": "^4.17.2",
|
|
59
|
-
"rollup-plugin-auto-external": "^2.0.0",
|
|
60
|
-
"sort-package-json": "^2.10.0",
|
|
61
|
-
"supertest": "^7.0.0",
|
|
62
|
-
"vitest": "^2.1.3"
|
|
63
|
-
}
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"gitHead": "26b6847fa8b061594bd899c2e098822dad198e51"
|
|
64
44
|
}
|
|
@@ -20,7 +20,7 @@ const decorateResponse = (
|
|
|
20
20
|
//
|
|
21
21
|
if (typeof res !== "object" || res === null) {
|
|
22
22
|
log.warn("decorateResponse called but response is not an object");
|
|
23
|
-
return;
|
|
23
|
+
return;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
try {
|
|
@@ -39,28 +39,28 @@ const decorateResponse = (
|
|
|
39
39
|
|
|
40
40
|
// X-Project-Environment
|
|
41
41
|
if (process.env.PROJECT_ENV) {
|
|
42
|
-
res.
|
|
42
|
+
res.set(HTTP.HEADER.PROJECT.ENVIRONMENT, process.env.PROJECT_ENV);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
// X-Project-Handler
|
|
46
46
|
if (handler) {
|
|
47
|
-
res.
|
|
47
|
+
res.set(HTTP.HEADER.PROJECT.HANDLER, handler);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
// X-Project-Invocation
|
|
51
51
|
const currentInvoke = getCurrentInvokeUuid();
|
|
52
52
|
if (currentInvoke) {
|
|
53
|
-
res.
|
|
53
|
+
res.set(HTTP.HEADER.PROJECT.INVOCATION, currentInvoke);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// X-Project-Key
|
|
57
57
|
if (process.env.PROJECT_KEY) {
|
|
58
|
-
res.
|
|
58
|
+
res.set(HTTP.HEADER.PROJECT.KEY, process.env.PROJECT_KEY);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
// X-Project-Version
|
|
62
62
|
if (version) {
|
|
63
|
-
res.
|
|
63
|
+
res.set(HTTP.HEADER.PROJECT.VERSION, version);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
//
|
package/src/expressHandler.js
CHANGED
|
@@ -30,7 +30,6 @@ const expressHandler = (handler, options = {}) => {
|
|
|
30
30
|
//
|
|
31
31
|
// Validate
|
|
32
32
|
//
|
|
33
|
-
/* eslint-disable no-autofix/prefer-const */
|
|
34
33
|
let {
|
|
35
34
|
locals,
|
|
36
35
|
name,
|
|
@@ -39,7 +38,6 @@ const expressHandler = (handler, options = {}) => {
|
|
|
39
38
|
unavailable,
|
|
40
39
|
validate,
|
|
41
40
|
} = options;
|
|
42
|
-
/* eslint-enable no-autofix/prefer-const */
|
|
43
41
|
validateIs.function(handler);
|
|
44
42
|
validateIs.optional.object(locals);
|
|
45
43
|
setup = force.array(setup); // allows a single item
|
|
@@ -155,7 +153,6 @@ const expressHandler = (handler, options = {}) => {
|
|
|
155
153
|
const key = keys[i];
|
|
156
154
|
libLogger.trace(`[jaypie] Locals: ${key}`);
|
|
157
155
|
if (typeof locals[key] === "function") {
|
|
158
|
-
// eslint-disable-next-line no-await-in-loop
|
|
159
156
|
localsReq.locals[key] = await locals[key](localsReq, localsRes);
|
|
160
157
|
} else {
|
|
161
158
|
localsReq.locals[key] = locals[key];
|
|
@@ -242,6 +239,7 @@ const expressHandler = (handler, options = {}) => {
|
|
|
242
239
|
} else if (typeof response === "string") {
|
|
243
240
|
try {
|
|
244
241
|
res.status(status).json(JSON.parse(response));
|
|
242
|
+
// eslint-disable-next-line no-unused-vars
|
|
245
243
|
} catch (error) {
|
|
246
244
|
res.status(status).send(response);
|
|
247
245
|
}
|
package/.eslintignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
dist/
|