serverless-offline 13.2.1 → 13.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +13 -22
- package/src/config/supportedRuntimes.js +2 -0
- package/src/events/http/HttpServer.js +28 -27
- package/src/events/websocket/lambda-events/WebSocketAuthorizerEvent.js +1 -5
- package/src/lambda/LambdaFunction.js +1 -3
- package/src/lambda/handler-runner/docker-runner/DockerContainer.js +4 -12
- package/src/lambda/routes/invocations/InvocationsController.js +2 -4
package/README.md
CHANGED
|
@@ -835,7 +835,7 @@ For example:
|
|
|
835
835
|
plugins:
|
|
836
836
|
- serverless-middleware # modifies some of your handler based on configuration
|
|
837
837
|
- serverless-webpack # package your javascript handlers using webpack
|
|
838
|
-
- serverless-dynamodb
|
|
838
|
+
- serverless-dynamodb # adds a local dynamo db
|
|
839
839
|
- serverless-offline # runs last so your code has been pre-processed and dynamo is ready
|
|
840
840
|
```
|
|
841
841
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dedicatedTo": "Blue, a great migrating bird.",
|
|
3
3
|
"name": "serverless-offline",
|
|
4
|
-
"version": "13.
|
|
4
|
+
"version": "13.3.1",
|
|
5
5
|
"description": "Emulate AWS λ and API Gateway locally when developing your Serverless project",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"exports": {
|
|
@@ -10,19 +10,13 @@
|
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
12
12
|
"scripts": {
|
|
13
|
-
"format": "eslint . --fix",
|
|
14
13
|
"lint": "eslint .",
|
|
15
|
-
"lint:
|
|
14
|
+
"lint:fix": "eslint . --fix",
|
|
16
15
|
"list-contributors": "echo 'clone https://github.com/mgechev/github-contributors-list.git first, then run npm install' && cd ../github-contributors-list && node bin/githubcontrib --owner dherault --repo serverless-offline --sortBy contributions --showlogin true --sortOrder desc > contributors.md",
|
|
17
|
-
"prepare": "
|
|
18
|
-
"prepare-release": "standard-version && prettier --write CHANGELOG.md",
|
|
16
|
+
"prepare-release": "commit-and-tag-version && prettier --write CHANGELOG.md",
|
|
19
17
|
"prepublishOnly": "npm run lint",
|
|
20
18
|
"prettier": "prettier --check .",
|
|
21
19
|
"prettier:fix": "prettier --write .",
|
|
22
|
-
"prettier-check": "prettier -c --ignore-path .gitignore \"**/*.{css,html,js,json,md,yaml,yml}\"",
|
|
23
|
-
"prettier-check:updated": "pipe-git-updated --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier -c",
|
|
24
|
-
"prettify": "prettier --write --ignore-path .gitignore \"**/*.{css,html,js,json,md,yaml,yml}\"",
|
|
25
|
-
"prettify:updated": "pipe-git-updated --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier --write",
|
|
26
20
|
"test": "mocha --require ./tests/mochaHooks.cjs",
|
|
27
21
|
"test:cov": "NODE_OPTIONS='--experimental-loader @istanbuljs/esm-loader-hook' nyc --reporter=html npm test",
|
|
28
22
|
"test:node": "TEST=unit mocha --require ./tests/mochaHooks.cjs",
|
|
@@ -54,7 +48,7 @@
|
|
|
54
48
|
"engines": {
|
|
55
49
|
"node": ">=18.12.0"
|
|
56
50
|
},
|
|
57
|
-
"
|
|
51
|
+
"commit-and-tag-version": {
|
|
58
52
|
"skip": {
|
|
59
53
|
"commit": true,
|
|
60
54
|
"tag": true
|
|
@@ -79,7 +73,7 @@
|
|
|
79
73
|
]
|
|
80
74
|
},
|
|
81
75
|
"dependencies": {
|
|
82
|
-
"@aws-sdk/client-lambda": "^3.
|
|
76
|
+
"@aws-sdk/client-lambda": "^3.468.0",
|
|
83
77
|
"@hapi/boom": "^10.0.1",
|
|
84
78
|
"@hapi/h2o2": "^10.0.4",
|
|
85
79
|
"@hapi/hapi": "^21.3.2",
|
|
@@ -89,15 +83,15 @@
|
|
|
89
83
|
"chalk": "^5.3.0",
|
|
90
84
|
"desm": "^1.3.0",
|
|
91
85
|
"execa": "^8.0.1",
|
|
92
|
-
"fs-extra": "^11.
|
|
86
|
+
"fs-extra": "^11.2.0",
|
|
93
87
|
"is-wsl": "^3.1.0",
|
|
94
88
|
"java-invoke-local": "0.0.6",
|
|
95
|
-
"jose": "^5.1.
|
|
89
|
+
"jose": "^5.1.2",
|
|
96
90
|
"js-string-escape": "^1.0.1",
|
|
97
91
|
"jsonpath-plus": "^7.2.0",
|
|
98
92
|
"jsonschema": "^1.4.1",
|
|
99
93
|
"jszip": "^3.10.1",
|
|
100
|
-
"luxon": "^3.
|
|
94
|
+
"luxon": "^3.4.4",
|
|
101
95
|
"node-schedule": "^2.1.1",
|
|
102
96
|
"p-memoize": "^7.1.1",
|
|
103
97
|
"p-retry": "^6.1.0",
|
|
@@ -107,20 +101,17 @@
|
|
|
107
101
|
"devDependencies": {
|
|
108
102
|
"@istanbuljs/esm-loader-hook": "^0.2.0",
|
|
109
103
|
"archiver": "^6.0.1",
|
|
110
|
-
"
|
|
104
|
+
"commit-and-tag-version": "^12.0.0",
|
|
105
|
+
"eslint": "^8.55.0",
|
|
111
106
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
112
|
-
"eslint-config-prettier": "^9.
|
|
107
|
+
"eslint-config-prettier": "^9.1.0",
|
|
113
108
|
"eslint-plugin-import": "^2.29.0",
|
|
114
109
|
"eslint-plugin-prettier": "^5.0.1",
|
|
115
110
|
"eslint-plugin-unicorn": "^49.0.0",
|
|
116
|
-
"git-list-updated": "^1.2.1",
|
|
117
|
-
"husky": "^8.0.3",
|
|
118
|
-
"lint-staged": "^15.0.2",
|
|
119
111
|
"mocha": "^10.2.0",
|
|
120
112
|
"nyc": "^15.1.0",
|
|
121
|
-
"prettier": "^3.0
|
|
122
|
-
"serverless": "^3.
|
|
123
|
-
"standard-version": "^9.5.0"
|
|
113
|
+
"prettier": "^3.1.0",
|
|
114
|
+
"serverless": "^3.38.0"
|
|
124
115
|
},
|
|
125
116
|
"peerDependencies": {
|
|
126
117
|
"serverless": "^3.2.0"
|
|
@@ -17,6 +17,7 @@ export const supportedNodejs = new Set([
|
|
|
17
17
|
'nodejs14.x',
|
|
18
18
|
'nodejs16.x',
|
|
19
19
|
'nodejs18.x',
|
|
20
|
+
'nodejs20.x',
|
|
20
21
|
])
|
|
21
22
|
|
|
22
23
|
// PROVIDED
|
|
@@ -50,5 +51,6 @@ export const unsupportedDockerRuntimes = new Set([
|
|
|
50
51
|
'nodejs14.x',
|
|
51
52
|
'nodejs16.x',
|
|
52
53
|
'nodejs18.x',
|
|
54
|
+
'nodejs20.x',
|
|
53
55
|
'python3.9',
|
|
54
56
|
])
|
|
@@ -748,33 +748,34 @@ export default class HttpServer {
|
|
|
748
748
|
// If there is a responseTemplate, we apply it to the result
|
|
749
749
|
const { responseTemplates } = chosenResponse
|
|
750
750
|
|
|
751
|
-
if (
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
751
|
+
if (
|
|
752
|
+
typeof responseTemplates === 'object' &&
|
|
753
|
+
keys(responseTemplates).length > 0
|
|
754
|
+
) {
|
|
755
|
+
// BAD IMPLEMENTATION: first key in responseTemplates
|
|
756
|
+
const responseTemplate = responseTemplates[responseContentType]
|
|
757
|
+
|
|
758
|
+
if (responseTemplate && responseTemplate !== '\n') {
|
|
759
|
+
log.debug('_____ RESPONSE TEMPLATE PROCCESSING _____')
|
|
760
|
+
log.debug(`Using responseTemplate '${responseContentType}'`)
|
|
761
|
+
|
|
762
|
+
try {
|
|
763
|
+
const reponseContext = new VelocityContext(
|
|
764
|
+
request,
|
|
765
|
+
stage,
|
|
766
|
+
result,
|
|
767
|
+
).getContext()
|
|
768
|
+
|
|
769
|
+
result = renderVelocityTemplateObject(
|
|
770
|
+
{
|
|
771
|
+
root: responseTemplate,
|
|
772
|
+
},
|
|
773
|
+
reponseContext,
|
|
774
|
+
).root
|
|
775
|
+
} catch (error) {
|
|
776
|
+
log.error(
|
|
777
|
+
`Error while parsing responseTemplate '${responseContentType}' for lambda ${functionKey}:\n${error.stack}`,
|
|
778
|
+
)
|
|
778
779
|
}
|
|
779
780
|
}
|
|
780
781
|
}
|
|
@@ -46,11 +46,7 @@ export default class WebSocketAuthorizerEvent {
|
|
|
46
46
|
|
|
47
47
|
return {
|
|
48
48
|
headers,
|
|
49
|
-
methodArn: `arn:aws:execute-api:${this.#provider.region}:${
|
|
50
|
-
requestContext.accountId
|
|
51
|
-
}:${requestContext.apiId}/${requestContext.stage}/${
|
|
52
|
-
requestContext.routeKey
|
|
53
|
-
}`,
|
|
49
|
+
methodArn: `arn:aws:execute-api:${this.#provider.region}:${requestContext.accountId}:${requestContext.apiId}/${requestContext.stage}/${requestContext.routeKey}`,
|
|
54
50
|
multiValueHeaders,
|
|
55
51
|
// NOTE: multiValueQueryStringParameters and queryStringParameters
|
|
56
52
|
// properties are only defined if they have values
|
|
@@ -176,9 +176,7 @@ export default class LambdaFunction {
|
|
|
176
176
|
if (!supportedRuntimes.has(this.#runtime)) {
|
|
177
177
|
log.warning()
|
|
178
178
|
log.warning(
|
|
179
|
-
`Warning: found unsupported runtime '${this.#runtime}' for function '${
|
|
180
|
-
this.#functionKey
|
|
181
|
-
}'`,
|
|
179
|
+
`Warning: found unsupported runtime '${this.#runtime}' for function '${this.#functionKey}'`,
|
|
182
180
|
)
|
|
183
181
|
}
|
|
184
182
|
}
|
|
@@ -138,9 +138,7 @@ export default class DockerContainer {
|
|
|
138
138
|
dockerArgs.push('-v', `${layerDir}:/opt:ro,delegated`)
|
|
139
139
|
} else {
|
|
140
140
|
log.warning(
|
|
141
|
-
`Provider ${
|
|
142
|
-
this.#provider.name
|
|
143
|
-
} is Unsupported. Layers are only supported on aws.`,
|
|
141
|
+
`Provider ${this.#provider.name} is Unsupported. Layers are only supported on aws.`,
|
|
144
142
|
)
|
|
145
143
|
}
|
|
146
144
|
}
|
|
@@ -255,9 +253,7 @@ export default class DockerContainer {
|
|
|
255
253
|
!layer.CompatibleRuntimes.includes(this.#runtime)
|
|
256
254
|
) {
|
|
257
255
|
log.warning(
|
|
258
|
-
`[${layerName}] Layer is not compatible with ${
|
|
259
|
-
this.#runtime
|
|
260
|
-
} runtime`,
|
|
256
|
+
`[${layerName}] Layer is not compatible with ${this.#runtime} runtime`,
|
|
261
257
|
)
|
|
262
258
|
|
|
263
259
|
return
|
|
@@ -349,9 +345,7 @@ export default class DockerContainer {
|
|
|
349
345
|
}
|
|
350
346
|
|
|
351
347
|
async #ping() {
|
|
352
|
-
const url = `http://${this.#dockerOptions.host}:${
|
|
353
|
-
this.#port
|
|
354
|
-
}/2018-06-01/ping`
|
|
348
|
+
const url = `http://${this.#dockerOptions.host}:${this.#port}/2018-06-01/ping`
|
|
355
349
|
const res = await fetch(url)
|
|
356
350
|
|
|
357
351
|
if (!res.ok) {
|
|
@@ -362,9 +356,7 @@ export default class DockerContainer {
|
|
|
362
356
|
}
|
|
363
357
|
|
|
364
358
|
async request(event) {
|
|
365
|
-
const url = `http://${this.#dockerOptions.host}:${
|
|
366
|
-
this.#port
|
|
367
|
-
}/2015-03-31/functions/${this.#functionKey}/invocations`
|
|
359
|
+
const url = `http://${this.#dockerOptions.host}:${this.#port}/2015-03-31/functions/${this.#functionKey}/invocations`
|
|
368
360
|
|
|
369
361
|
const res = await fetch(url, {
|
|
370
362
|
body: stringify(event),
|
|
@@ -70,10 +70,8 @@ export default class InvocationsController {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
// Checking if the result of the Lambda Invoke is a primitive string to wrap it. this is for future post-processing such as Step Functions Tasks
|
|
73
|
-
if (result) {
|
|
74
|
-
|
|
75
|
-
result = `"${result}"`
|
|
76
|
-
}
|
|
73
|
+
if (result && typeof result === 'string') {
|
|
74
|
+
result = `"${result}"`
|
|
77
75
|
}
|
|
78
76
|
|
|
79
77
|
// result is actually the Payload.
|