serverless-offline 13.3.2 → 13.3.3
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 +17 -17
- package/package.json +14 -13
- package/src/ServerlessOffline.js +42 -42
- package/src/config/colors.js +9 -9
- package/src/config/commandOptions.js +61 -61
- package/src/config/constants.js +5 -5
- package/src/config/defaultOptions.js +6 -6
- package/src/config/index.js +4 -4
- package/src/config/supportedRuntimes.js +18 -18
- package/src/errors/index.js +1 -1
- package/src/events/alb/Alb.js +2 -2
- package/src/events/alb/AlbEventDefinition.js +2 -2
- package/src/events/alb/HttpServer.js +54 -54
- package/src/events/alb/index.js +1 -1
- package/src/events/alb/lambda-events/LambdaAlbRequestEvent.js +2 -2
- package/src/events/alb/lambda-events/index.js +1 -1
- package/src/events/authCanExecuteResource.js +3 -3
- package/src/events/authFunctionNameExtractor.js +9 -9
- package/src/events/authMatchPolicyResource.js +8 -8
- package/src/events/authValidateContext.js +11 -11
- package/src/events/http/Endpoint.js +26 -26
- package/src/events/http/Http.js +2 -2
- package/src/events/http/HttpEventDefinition.js +2 -2
- package/src/events/http/HttpServer.js +156 -156
- package/src/events/http/OfflineEndpoint.js +7 -7
- package/src/events/http/authJWTSettingsExtractor.js +2 -2
- package/src/events/http/createAuthScheme.js +29 -27
- package/src/events/http/createJWTAuthScheme.js +12 -12
- package/src/events/http/index.js +1 -1
- package/src/events/http/javaHelpers.js +2 -2
- package/src/events/http/lambda-events/LambdaIntegrationEvent.js +5 -5
- package/src/events/http/lambda-events/LambdaProxyIntegrationEvent.js +47 -47
- package/src/events/http/lambda-events/LambdaProxyIntegrationEventV2.js +27 -27
- package/src/events/http/lambda-events/VelocityContext.js +28 -32
- package/src/events/http/lambda-events/index.js +4 -4
- package/src/events/http/lambda-events/renderVelocityTemplateObject.js +13 -13
- package/src/events/http/parseResources.js +6 -6
- package/src/events/http/payloadSchemaValidator.js +2 -2
- package/src/events/schedule/Schedule.js +21 -21
- package/src/events/schedule/ScheduleEvent.js +7 -7
- package/src/events/schedule/ScheduleEventDefinition.js +1 -1
- package/src/events/schedule/index.js +1 -1
- package/src/events/websocket/HttpServer.js +9 -9
- package/src/events/websocket/WebSocket.js +4 -4
- package/src/events/websocket/WebSocketClients.js +29 -29
- package/src/events/websocket/WebSocketEventDefinition.js +1 -1
- package/src/events/websocket/WebSocketServer.js +9 -9
- package/src/events/websocket/http-routes/_catchAll/catchAllRoute.js +3 -3
- package/src/events/websocket/http-routes/_catchAll/index.js +1 -1
- package/src/events/websocket/http-routes/connections/ConnectionsController.js +1 -1
- package/src/events/websocket/http-routes/connections/connectionsRoutes.js +6 -6
- package/src/events/websocket/http-routes/connections/index.js +1 -1
- package/src/events/websocket/http-routes/index.js +2 -2
- package/src/events/websocket/index.js +1 -1
- package/src/events/websocket/lambda-events/WebSocketAuthorizerEvent.js +5 -5
- package/src/events/websocket/lambda-events/WebSocketConnectEvent.js +7 -6
- package/src/events/websocket/lambda-events/WebSocketDisconnectEvent.js +5 -5
- package/src/events/websocket/lambda-events/WebSocketEvent.js +2 -2
- package/src/events/websocket/lambda-events/WebSocketRequestContext.js +12 -11
- package/src/events/websocket/lambda-events/index.js +4 -4
- package/src/index.js +1 -1
- package/src/lambda/HttpServer.js +11 -11
- package/src/lambda/Lambda.js +2 -2
- package/src/lambda/LambdaContext.js +1 -1
- package/src/lambda/LambdaFunction.js +34 -34
- package/src/lambda/LambdaFunctionPool.js +3 -3
- package/src/lambda/handler-runner/HandlerRunner.js +12 -12
- package/src/lambda/handler-runner/docker-runner/DockerContainer.js +59 -59
- package/src/lambda/handler-runner/docker-runner/DockerImage.js +6 -6
- package/src/lambda/handler-runner/docker-runner/DockerRunner.js +2 -2
- package/src/lambda/handler-runner/docker-runner/index.js +1 -1
- package/src/lambda/handler-runner/go-runner/GoRunner.js +34 -34
- package/src/lambda/handler-runner/go-runner/index.js +1 -1
- package/src/lambda/handler-runner/in-process-runner/InProcessRunner.js +7 -7
- package/src/lambda/handler-runner/in-process-runner/aws-lambda-ric/UserFunction.js +52 -52
- package/src/lambda/handler-runner/in-process-runner/index.js +1 -1
- package/src/lambda/handler-runner/index.js +1 -1
- package/src/lambda/handler-runner/java-runner/JavaRunner.js +13 -13
- package/src/lambda/handler-runner/java-runner/index.js +1 -1
- package/src/lambda/handler-runner/python-runner/PythonRunner.js +21 -21
- package/src/lambda/handler-runner/python-runner/index.js +1 -1
- package/src/lambda/handler-runner/ruby-runner/RubyRunner.js +11 -11
- package/src/lambda/handler-runner/ruby-runner/index.js +1 -1
- package/src/lambda/handler-runner/worker-thread-runner/WorkerThreadRunner.js +6 -6
- package/src/lambda/handler-runner/worker-thread-runner/index.js +1 -1
- package/src/lambda/handler-runner/worker-thread-runner/workerThreadHelper.js +4 -4
- package/src/lambda/index.js +1 -1
- package/src/lambda/routes/index.js +2 -2
- package/src/lambda/routes/invocations/InvocationsController.js +11 -11
- package/src/lambda/routes/invocations/index.js +1 -1
- package/src/lambda/routes/invocations/invocationsRoute.js +15 -15
- package/src/lambda/routes/invoke-async/index.js +1 -1
- package/src/lambda/routes/invoke-async/invokeAsyncRoute.js +6 -6
- package/src/utils/checkDockerDaemon.js +8 -8
- package/src/utils/checkGoVersion.js +3 -3
- package/src/utils/createApiKey.js +2 -2
- package/src/utils/detectExecutable.js +2 -2
- package/src/utils/formatToClfTime.js +2 -2
- package/src/utils/generateHapiPath.js +8 -8
- package/src/utils/getApiKeysValues.js +2 -2
- package/src/utils/getHttpApiCorsConfig.js +11 -11
- package/src/utils/getRawQueryParams.js +2 -2
- package/src/utils/index.js +25 -26
- package/src/utils/jsonPath.js +1 -1
- package/src/utils/logRoutes.js +13 -13
- package/src/utils/parseHeaders.js +1 -1
- package/src/utils/parseMultiValueHeaders.js +1 -1
- package/src/utils/parseMultiValueQueryStringParameters.js +1 -1
- package/src/utils/parseQueryStringParameters.js +1 -1
- package/src/utils/parseQueryStringParametersForPayloadV2.js +1 -1
- package/src/utils/splitHandlerPathAndName.js +3 -3
- package/src/utils/createUniqueId.js +0 -5
package/README.md
CHANGED
|
@@ -304,45 +304,45 @@ the Lambda handler process is running in a child process.
|
|
|
304
304
|
To use `Lambda.invoke` you need to set the lambda endpoint to the `serverless-offline` endpoint:
|
|
305
305
|
|
|
306
306
|
```js
|
|
307
|
-
import { env } from
|
|
308
|
-
import aws from
|
|
307
|
+
import { env } from "node:process"
|
|
308
|
+
import aws from "aws-sdk"
|
|
309
309
|
|
|
310
310
|
const lambda = new aws.Lambda({
|
|
311
|
-
apiVersion:
|
|
311
|
+
apiVersion: "2015-03-31",
|
|
312
312
|
// endpoint needs to be set only if it deviates from the default
|
|
313
313
|
endpoint: env.IS_OFFLINE
|
|
314
|
-
?
|
|
315
|
-
:
|
|
314
|
+
? "http://localhost:3002"
|
|
315
|
+
: "https://lambda.us-east-1.amazonaws.com",
|
|
316
316
|
})
|
|
317
317
|
```
|
|
318
318
|
|
|
319
319
|
All your lambdas can then be invoked in a handler using
|
|
320
320
|
|
|
321
321
|
```js
|
|
322
|
-
import { Buffer } from
|
|
323
|
-
import aws from
|
|
322
|
+
import { Buffer } from "node:buffer"
|
|
323
|
+
import aws from "aws-sdk"
|
|
324
324
|
|
|
325
325
|
const { stringify } = JSON
|
|
326
326
|
|
|
327
327
|
const lambda = new aws.Lambda({
|
|
328
|
-
apiVersion:
|
|
329
|
-
endpoint:
|
|
328
|
+
apiVersion: "2015-03-31",
|
|
329
|
+
endpoint: "http://localhost:3002",
|
|
330
330
|
})
|
|
331
331
|
|
|
332
332
|
export async function handler() {
|
|
333
333
|
const clientContextData = stringify({
|
|
334
|
-
foo:
|
|
334
|
+
foo: "foo",
|
|
335
335
|
})
|
|
336
336
|
|
|
337
337
|
const payload = stringify({
|
|
338
|
-
data:
|
|
338
|
+
data: "foo",
|
|
339
339
|
})
|
|
340
340
|
|
|
341
341
|
const params = {
|
|
342
|
-
ClientContext: Buffer.from(clientContextData).toString(
|
|
342
|
+
ClientContext: Buffer.from(clientContextData).toString("base64"),
|
|
343
343
|
// FunctionName is composed of: service name - stage - function name, e.g.
|
|
344
|
-
FunctionName:
|
|
345
|
-
InvocationType:
|
|
344
|
+
FunctionName: "myServiceName-dev-invokedHandler",
|
|
345
|
+
InvocationType: "RequestResponse",
|
|
346
346
|
Payload: payload,
|
|
347
347
|
}
|
|
348
348
|
|
|
@@ -544,8 +544,8 @@ module.exports = function (endpoint, functionKey, method, path) {
|
|
|
544
544
|
}
|
|
545
545
|
},
|
|
546
546
|
|
|
547
|
-
name:
|
|
548
|
-
scheme:
|
|
547
|
+
name: "your strategy name",
|
|
548
|
+
scheme: "your scheme name",
|
|
549
549
|
}
|
|
550
550
|
}
|
|
551
551
|
```
|
|
@@ -697,7 +697,7 @@ custom:
|
|
|
697
697
|
serverless-offline:
|
|
698
698
|
resourceRoutes:
|
|
699
699
|
YourCloudFormationMethodId:
|
|
700
|
-
Uri:
|
|
700
|
+
Uri: "http://localhost:3001/assets/{proxy}"
|
|
701
701
|
```
|
|
702
702
|
|
|
703
703
|
### Response parameters
|
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.3.
|
|
4
|
+
"version": "13.3.3",
|
|
5
5
|
"description": "Emulate AWS λ and API Gateway locally when developing your Serverless project",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"exports": {
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
12
12
|
"scripts": {
|
|
13
|
+
"code-quality": "npm run prettier && npm run lint",
|
|
13
14
|
"lint": "eslint .",
|
|
14
15
|
"lint:fix": "eslint . --fix",
|
|
15
16
|
"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",
|
|
@@ -73,7 +74,7 @@
|
|
|
73
74
|
]
|
|
74
75
|
},
|
|
75
76
|
"dependencies": {
|
|
76
|
-
"@aws-sdk/client-lambda": "^3.
|
|
77
|
+
"@aws-sdk/client-lambda": "^3.496.0",
|
|
77
78
|
"@hapi/boom": "^10.0.1",
|
|
78
79
|
"@hapi/h2o2": "^10.0.4",
|
|
79
80
|
"@hapi/hapi": "^21.3.2",
|
|
@@ -81,36 +82,36 @@
|
|
|
81
82
|
"array-unflat-js": "^0.1.3",
|
|
82
83
|
"boxen": "^7.1.1",
|
|
83
84
|
"chalk": "^5.3.0",
|
|
84
|
-
"desm": "^1.3.
|
|
85
|
+
"desm": "^1.3.1",
|
|
85
86
|
"execa": "^8.0.1",
|
|
86
87
|
"fs-extra": "^11.2.0",
|
|
87
88
|
"is-wsl": "^3.1.0",
|
|
88
89
|
"java-invoke-local": "0.0.6",
|
|
89
|
-
"jose": "^5.
|
|
90
|
+
"jose": "^5.2.0",
|
|
90
91
|
"js-string-escape": "^1.0.1",
|
|
91
|
-
"jsonpath-plus": "^
|
|
92
|
+
"jsonpath-plus": "^8.0.0",
|
|
92
93
|
"jsonschema": "^1.4.1",
|
|
93
94
|
"jszip": "^3.10.1",
|
|
94
95
|
"luxon": "^3.4.4",
|
|
95
96
|
"node-schedule": "^2.1.1",
|
|
96
97
|
"p-memoize": "^7.1.1",
|
|
97
|
-
"p-retry": "^6.
|
|
98
|
+
"p-retry": "^6.2.0",
|
|
98
99
|
"velocityjs": "^2.0.6",
|
|
99
|
-
"ws": "^8.
|
|
100
|
+
"ws": "^8.16.0"
|
|
100
101
|
},
|
|
101
102
|
"devDependencies": {
|
|
102
103
|
"@istanbuljs/esm-loader-hook": "^0.2.0",
|
|
103
104
|
"archiver": "^6.0.1",
|
|
104
|
-
"commit-and-tag-version": "^12.
|
|
105
|
-
"eslint": "^8.
|
|
105
|
+
"commit-and-tag-version": "^12.2.0",
|
|
106
|
+
"eslint": "^8.56.0",
|
|
106
107
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
107
108
|
"eslint-config-prettier": "^9.1.0",
|
|
108
|
-
"eslint-plugin-import": "^2.29.
|
|
109
|
-
"eslint-plugin-prettier": "^5.
|
|
110
|
-
"eslint-plugin-unicorn": "^
|
|
109
|
+
"eslint-plugin-import": "^2.29.1",
|
|
110
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
111
|
+
"eslint-plugin-unicorn": "^50.0.1",
|
|
111
112
|
"mocha": "^10.2.0",
|
|
112
113
|
"nyc": "^15.1.0",
|
|
113
|
-
"prettier": "^3.
|
|
114
|
+
"prettier": "^3.2.4",
|
|
114
115
|
"serverless": "^3.38.0"
|
|
115
116
|
},
|
|
116
117
|
"peerDependencies": {
|
package/src/ServerlessOffline.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import process, { exit } from
|
|
2
|
-
import { log } from
|
|
1
|
+
import process, { exit } from "node:process"
|
|
2
|
+
import { log } from "@serverless/utils/log.js"
|
|
3
3
|
import {
|
|
4
4
|
commandOptions,
|
|
5
5
|
CUSTOM_OPTION,
|
|
6
6
|
defaultOptions,
|
|
7
7
|
SERVER_SHUTDOWN_TIMEOUT,
|
|
8
|
-
} from
|
|
9
|
-
import { gray } from
|
|
8
|
+
} from "./config/index.js"
|
|
9
|
+
import { gray } from "./config/colors.js"
|
|
10
10
|
|
|
11
11
|
export default class ServerlessOffline {
|
|
12
12
|
#alb = null
|
|
@@ -30,28 +30,28 @@ export default class ServerlessOffline {
|
|
|
30
30
|
// add start nested options
|
|
31
31
|
commands: {
|
|
32
32
|
functionsUpdated: {
|
|
33
|
-
lifecycleEvents: [
|
|
34
|
-
type:
|
|
33
|
+
lifecycleEvents: ["cleanup"],
|
|
34
|
+
type: "entrypoint",
|
|
35
35
|
},
|
|
36
36
|
start: {
|
|
37
|
-
lifecycleEvents: [
|
|
37
|
+
lifecycleEvents: ["init", "ready", "end"],
|
|
38
38
|
options: commandOptions,
|
|
39
39
|
usage:
|
|
40
|
-
|
|
40
|
+
"Simulates API Gateway to call your lambda functions offline using backward compatible initialization.",
|
|
41
41
|
},
|
|
42
42
|
},
|
|
43
|
-
lifecycleEvents: [
|
|
43
|
+
lifecycleEvents: ["start"],
|
|
44
44
|
options: commandOptions,
|
|
45
|
-
usage:
|
|
45
|
+
usage: "Simulates API Gateway to call your lambda functions offline.",
|
|
46
46
|
},
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
hooks = {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
"offline:functionsUpdated:cleanup": this.#cleanupFunctions.bind(this),
|
|
51
|
+
"offline:start": this.#startWithExplicitEnd.bind(this),
|
|
52
|
+
"offline:start:end": this.end.bind(this),
|
|
53
|
+
"offline:start:init": this.start.bind(this),
|
|
54
|
+
"offline:start:ready": this.#ready.bind(this),
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
constructor(serverless, cliOptions) {
|
|
@@ -102,7 +102,7 @@ export default class ServerlessOffline {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
async end(skipExit) {
|
|
105
|
-
log.info(
|
|
105
|
+
log.info("Halting offline server")
|
|
106
106
|
|
|
107
107
|
const eventModules = []
|
|
108
108
|
|
|
@@ -138,7 +138,7 @@ export default class ServerlessOffline {
|
|
|
138
138
|
|
|
139
139
|
async #cleanupFunctions() {
|
|
140
140
|
if (this.#lambda) {
|
|
141
|
-
log.debug(
|
|
141
|
+
log.debug("Forcing cleanup of Lambda functions")
|
|
142
142
|
await this.#lambda.cleanup()
|
|
143
143
|
}
|
|
144
144
|
}
|
|
@@ -159,18 +159,18 @@ export default class ServerlessOffline {
|
|
|
159
159
|
const command = await new Promise((resolve) => {
|
|
160
160
|
process
|
|
161
161
|
// SIGINT will be usually sent when user presses ctrl+c
|
|
162
|
-
.on(
|
|
162
|
+
.on("SIGINT", () => resolve("SIGINT"))
|
|
163
163
|
// SIGTERM is a default termination signal in many cases,
|
|
164
164
|
// for example when "killing" a subprocess spawned in node
|
|
165
165
|
// with child_process methods
|
|
166
|
-
.on(
|
|
166
|
+
.on("SIGTERM", () => resolve("SIGTERM"))
|
|
167
167
|
})
|
|
168
168
|
|
|
169
169
|
log.info(`Got ${command} signal. Offline Halting...`)
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
async #createLambda(lambdas, skipStart) {
|
|
173
|
-
const { default: Lambda } = await import(
|
|
173
|
+
const { default: Lambda } = await import("./lambda/index.js")
|
|
174
174
|
|
|
175
175
|
this.#lambda = new Lambda(this.#serverless, this.#options)
|
|
176
176
|
|
|
@@ -182,7 +182,7 @@ export default class ServerlessOffline {
|
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
async #createHttp(events, skipStart) {
|
|
185
|
-
const { default: Http } = await import(
|
|
185
|
+
const { default: Http } = await import("./events/http/index.js")
|
|
186
186
|
|
|
187
187
|
this.#http = new Http(this.#serverless, this.#options, this.#lambda)
|
|
188
188
|
|
|
@@ -204,7 +204,7 @@ export default class ServerlessOffline {
|
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
async #createSchedule(events) {
|
|
207
|
-
const { default: Schedule } = await import(
|
|
207
|
+
const { default: Schedule } = await import("./events/schedule/index.js")
|
|
208
208
|
|
|
209
209
|
this.#schedule = new Schedule(
|
|
210
210
|
this.#lambda,
|
|
@@ -215,7 +215,7 @@ export default class ServerlessOffline {
|
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
async #createWebSocket(events) {
|
|
218
|
-
const { default: WebSocket } = await import(
|
|
218
|
+
const { default: WebSocket } = await import("./events/websocket/index.js")
|
|
219
219
|
|
|
220
220
|
this.#webSocket = new WebSocket(
|
|
221
221
|
this.#serverless,
|
|
@@ -231,7 +231,7 @@ export default class ServerlessOffline {
|
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
async #createAlb(events, skipStart) {
|
|
234
|
-
const { default: Alb } = await import(
|
|
234
|
+
const { default: Alb } = await import("./events/alb/index.js")
|
|
235
235
|
|
|
236
236
|
this.#alb = new Alb(this.#serverless, this.#options, this.#lambda)
|
|
237
237
|
|
|
@@ -261,14 +261,14 @@ export default class ServerlessOffline {
|
|
|
261
261
|
|
|
262
262
|
// Parse CORS options
|
|
263
263
|
this.#options.corsAllowHeaders = this.#options.corsAllowHeaders
|
|
264
|
-
.replaceAll(
|
|
265
|
-
.split(
|
|
264
|
+
.replaceAll(" ", "")
|
|
265
|
+
.split(",")
|
|
266
266
|
this.#options.corsAllowOrigin = this.#options.corsAllowOrigin
|
|
267
|
-
.replaceAll(
|
|
268
|
-
.split(
|
|
267
|
+
.replaceAll(" ", "")
|
|
268
|
+
.split(",")
|
|
269
269
|
this.#options.corsExposedHeaders = this.#options.corsExposedHeaders
|
|
270
|
-
.replaceAll(
|
|
271
|
-
.split(
|
|
270
|
+
.replaceAll(" ", "")
|
|
271
|
+
.split(",")
|
|
272
272
|
|
|
273
273
|
this.#options.corsConfig = {
|
|
274
274
|
credentials: !this.#options.corsDisallowCredentials,
|
|
@@ -284,7 +284,7 @@ export default class ServerlessOffline {
|
|
|
284
284
|
} ${gray(`(${this.#options.region || provider.region})`)}`,
|
|
285
285
|
)
|
|
286
286
|
log.notice()
|
|
287
|
-
log.debug(
|
|
287
|
+
log.debug("options:", this.#options)
|
|
288
288
|
}
|
|
289
289
|
|
|
290
290
|
#getEvents() {
|
|
@@ -339,27 +339,27 @@ export default class ServerlessOffline {
|
|
|
339
339
|
|
|
340
340
|
// Ensure definitions for 'httpApi' events are objects so that they can be marked
|
|
341
341
|
// with an 'isHttpApi' property (they are handled differently to 'http' events)
|
|
342
|
-
if (typeof httpApiEvent.http ===
|
|
342
|
+
if (typeof httpApiEvent.http === "string") {
|
|
343
343
|
httpApiEvent.http = {
|
|
344
344
|
routeKey:
|
|
345
|
-
httpApiEvent.http ===
|
|
345
|
+
httpApiEvent.http === "*" ? "$default" : httpApiEvent.http,
|
|
346
346
|
}
|
|
347
|
-
} else if (typeof httpApiEvent.http ===
|
|
347
|
+
} else if (typeof httpApiEvent.http === "object") {
|
|
348
348
|
if (!httpApiEvent.http.method) {
|
|
349
349
|
log.warning(
|
|
350
350
|
`Event definition is missing a method for function "${functionKey}"`,
|
|
351
351
|
)
|
|
352
|
-
httpApiEvent.http.method =
|
|
352
|
+
httpApiEvent.http.method = ""
|
|
353
353
|
}
|
|
354
354
|
if (
|
|
355
|
-
httpApiEvent.http.method ===
|
|
356
|
-
httpApiEvent.http.path ===
|
|
355
|
+
httpApiEvent.http.method === "*" &&
|
|
356
|
+
httpApiEvent.http.path === "*"
|
|
357
357
|
) {
|
|
358
|
-
httpApiEvent.http.routeKey =
|
|
358
|
+
httpApiEvent.http.routeKey = "$default"
|
|
359
359
|
} else {
|
|
360
360
|
const resolvedMethod =
|
|
361
|
-
httpApiEvent.http.method ===
|
|
362
|
-
?
|
|
361
|
+
httpApiEvent.http.method === "*"
|
|
362
|
+
? "ANY"
|
|
363
363
|
: httpApiEvent.http.method.toUpperCase()
|
|
364
364
|
httpApiEvent.http.routeKey = `${resolvedMethod} ${httpApiEvent.http.path}`
|
|
365
365
|
}
|
|
@@ -371,7 +371,7 @@ export default class ServerlessOffline {
|
|
|
371
371
|
log.warning(
|
|
372
372
|
`Event definition must be a string or object but received ${typeof httpApiEvent.http} for function "${functionKey}"`,
|
|
373
373
|
)
|
|
374
|
-
httpApiEvent.http.routeKey =
|
|
374
|
+
httpApiEvent.http.routeKey = ""
|
|
375
375
|
}
|
|
376
376
|
|
|
377
377
|
httpApiEvent.http.isHttpApi = true
|
|
@@ -385,7 +385,7 @@ export default class ServerlessOffline {
|
|
|
385
385
|
httpApiEvent.http.payload =
|
|
386
386
|
service.provider.httpApi && service.provider.httpApi.payload
|
|
387
387
|
? service.provider.httpApi.payload
|
|
388
|
-
:
|
|
388
|
+
: "2.0"
|
|
389
389
|
}
|
|
390
390
|
|
|
391
391
|
httpApiEvents.push(httpApiEvent)
|
package/src/config/colors.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import chalk from
|
|
1
|
+
import chalk from "chalk"
|
|
2
2
|
|
|
3
|
-
export const dodgerblue = chalk.hex(
|
|
4
|
-
export const gray = chalk.hex(
|
|
5
|
-
export const lime = chalk.hex(
|
|
6
|
-
export const orange = chalk.hex(
|
|
7
|
-
export const peachpuff = chalk.hex(
|
|
8
|
-
export const plum = chalk.hex(
|
|
9
|
-
export const red = chalk.hex(
|
|
10
|
-
export const yellow = chalk.hex(
|
|
3
|
+
export const dodgerblue = chalk.hex("#1e90ff")
|
|
4
|
+
export const gray = chalk.hex("#808080")
|
|
5
|
+
export const lime = chalk.hex("#00ff00")
|
|
6
|
+
export const orange = chalk.hex("#ffa500")
|
|
7
|
+
export const peachpuff = chalk.hex("#ffdab9")
|
|
8
|
+
export const plum = chalk.hex("#dda0dd")
|
|
9
|
+
export const red = chalk.hex("#ff0000")
|
|
10
|
+
export const yellow = chalk.hex("#ffff00")
|
|
@@ -1,138 +1,138 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
albPort: {
|
|
3
|
-
type:
|
|
4
|
-
usage:
|
|
3
|
+
type: "string",
|
|
4
|
+
usage: "ALB port to listen on. Default: 3003.",
|
|
5
5
|
},
|
|
6
6
|
corsAllowHeaders: {
|
|
7
|
-
type:
|
|
7
|
+
type: "string",
|
|
8
8
|
usage:
|
|
9
|
-
|
|
9
|
+
"Used to build the Access-Control-Allow-Headers header for CORS support.",
|
|
10
10
|
},
|
|
11
11
|
corsAllowOrigin: {
|
|
12
|
-
type:
|
|
12
|
+
type: "string",
|
|
13
13
|
usage:
|
|
14
|
-
|
|
14
|
+
"Used to build the Access-Control-Allow-Origin header for CORS support.",
|
|
15
15
|
},
|
|
16
16
|
corsDisallowCredentials: {
|
|
17
|
-
type:
|
|
17
|
+
type: "boolean",
|
|
18
18
|
usage:
|
|
19
|
-
|
|
19
|
+
"Used to override the Access-Control-Allow-Credentials default (which is true) to false.",
|
|
20
20
|
},
|
|
21
21
|
corsExposedHeaders: {
|
|
22
|
-
type:
|
|
22
|
+
type: "string",
|
|
23
23
|
usage:
|
|
24
|
-
|
|
24
|
+
"Used to build the Access-Control-Exposed-Headers response header for CORS support.",
|
|
25
25
|
},
|
|
26
26
|
disableCookieValidation: {
|
|
27
|
-
type:
|
|
28
|
-
usage:
|
|
27
|
+
type: "boolean",
|
|
28
|
+
usage: "Used to disable cookie-validation on hapi.js-server.",
|
|
29
29
|
},
|
|
30
30
|
dockerHost: {
|
|
31
|
-
type:
|
|
32
|
-
usage:
|
|
31
|
+
type: "string",
|
|
32
|
+
usage: "The host name of Docker. Default: localhost.",
|
|
33
33
|
},
|
|
34
34
|
dockerHostServicePath: {
|
|
35
|
-
type:
|
|
35
|
+
type: "string",
|
|
36
36
|
usage:
|
|
37
|
-
|
|
37
|
+
"Defines service path which is used by SLS running inside Docker container.",
|
|
38
38
|
},
|
|
39
39
|
dockerNetwork: {
|
|
40
|
-
type:
|
|
41
|
-
usage:
|
|
40
|
+
type: "string",
|
|
41
|
+
usage: "The network that the Docker container will connect to.",
|
|
42
42
|
},
|
|
43
43
|
dockerReadOnly: {
|
|
44
|
-
type:
|
|
45
|
-
usage:
|
|
44
|
+
type: "boolean",
|
|
45
|
+
usage: "Marks if the docker code layer should be read only. Default: true.",
|
|
46
46
|
},
|
|
47
47
|
enforceSecureCookies: {
|
|
48
|
-
type:
|
|
49
|
-
usage:
|
|
48
|
+
type: "boolean",
|
|
49
|
+
usage: "Enforce secure cookies.",
|
|
50
50
|
},
|
|
51
51
|
host: {
|
|
52
|
-
shortcut:
|
|
53
|
-
type:
|
|
54
|
-
usage:
|
|
52
|
+
shortcut: "o",
|
|
53
|
+
type: "string",
|
|
54
|
+
usage: "The host name to listen on. Default: localhost.",
|
|
55
55
|
},
|
|
56
56
|
httpPort: {
|
|
57
|
-
type:
|
|
58
|
-
usage:
|
|
57
|
+
type: "string",
|
|
58
|
+
usage: "HTTP port to listen on. Default: 3000.",
|
|
59
59
|
},
|
|
60
60
|
httpsProtocol: {
|
|
61
|
-
shortcut:
|
|
62
|
-
type:
|
|
61
|
+
shortcut: "H",
|
|
62
|
+
type: "string",
|
|
63
63
|
usage:
|
|
64
|
-
|
|
64
|
+
"To enable HTTPS, specify directory (relative to your cwd, typically your project dir) for both cert.pem and key.pem files.",
|
|
65
65
|
},
|
|
66
66
|
ignoreJWTSignature: {
|
|
67
|
-
type:
|
|
67
|
+
type: "boolean",
|
|
68
68
|
usage:
|
|
69
69
|
"When using HttpApi with a JWT authorizer, don't check the signature of the JWT token.",
|
|
70
70
|
},
|
|
71
71
|
lambdaPort: {
|
|
72
|
-
type:
|
|
73
|
-
usage:
|
|
72
|
+
type: "string",
|
|
73
|
+
usage: "Lambda http port to listen on. Default: 3002.",
|
|
74
74
|
},
|
|
75
75
|
layersDir: {
|
|
76
|
-
type:
|
|
76
|
+
type: "string",
|
|
77
77
|
usage:
|
|
78
|
-
|
|
78
|
+
"The directory layers should be stored in. Default: {codeDir}/.serverless-offline/layers.",
|
|
79
79
|
},
|
|
80
80
|
localEnvironment: {
|
|
81
|
-
type:
|
|
82
|
-
usage:
|
|
81
|
+
type: "boolean",
|
|
82
|
+
usage: "Copy local environment variables. Default: false.",
|
|
83
83
|
},
|
|
84
84
|
noAuth: {
|
|
85
|
-
type:
|
|
86
|
-
usage:
|
|
85
|
+
type: "boolean",
|
|
86
|
+
usage: "Turns off all authorizers.",
|
|
87
87
|
},
|
|
88
88
|
noPrependStageInUrl: {
|
|
89
|
-
type:
|
|
89
|
+
type: "boolean",
|
|
90
90
|
usage: "Don't prepend http routes with the stage.",
|
|
91
91
|
},
|
|
92
92
|
noTimeout: {
|
|
93
|
-
shortcut:
|
|
94
|
-
type:
|
|
95
|
-
usage:
|
|
93
|
+
shortcut: "t",
|
|
94
|
+
type: "boolean",
|
|
95
|
+
usage: "Disables the timeout feature.",
|
|
96
96
|
},
|
|
97
97
|
prefix: {
|
|
98
|
-
shortcut:
|
|
99
|
-
type:
|
|
98
|
+
shortcut: "p",
|
|
99
|
+
type: "string",
|
|
100
100
|
usage:
|
|
101
|
-
|
|
101
|
+
"Adds a prefix to every path, to send your requests to http://localhost:3000/prefix/[your_path] instead.",
|
|
102
102
|
},
|
|
103
103
|
reloadHandler: {
|
|
104
|
-
type:
|
|
105
|
-
usage:
|
|
104
|
+
type: "boolean",
|
|
105
|
+
usage: "Reloads handler with each request.",
|
|
106
106
|
},
|
|
107
107
|
resourceRoutes: {
|
|
108
|
-
type:
|
|
109
|
-
usage:
|
|
108
|
+
type: "boolean",
|
|
109
|
+
usage: "Turns on loading of your HTTP proxy settings from serverless.yml.",
|
|
110
110
|
},
|
|
111
111
|
terminateIdleLambdaTime: {
|
|
112
|
-
type:
|
|
112
|
+
type: "string",
|
|
113
113
|
usage:
|
|
114
|
-
|
|
114
|
+
"Number of seconds until an idle function is eligible for termination.",
|
|
115
115
|
},
|
|
116
116
|
useDocker: {
|
|
117
|
-
type:
|
|
118
|
-
usage:
|
|
117
|
+
type: "boolean",
|
|
118
|
+
usage: "Uses docker for node/python/ruby/provided.",
|
|
119
119
|
},
|
|
120
120
|
useInProcess: {
|
|
121
|
-
type:
|
|
121
|
+
type: "boolean",
|
|
122
122
|
usage: "Run handlers in the same process as 'serverless-offline'.",
|
|
123
123
|
},
|
|
124
124
|
webSocketHardTimeout: {
|
|
125
|
-
type:
|
|
125
|
+
type: "string",
|
|
126
126
|
usage:
|
|
127
|
-
|
|
127
|
+
"Set WebSocket hard timeout in seconds to reproduce AWS limits (https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html#apigateway-execution-service-websocket-limits-table). Default: 7200 (2 hours).",
|
|
128
128
|
},
|
|
129
129
|
webSocketIdleTimeout: {
|
|
130
|
-
type:
|
|
130
|
+
type: "string",
|
|
131
131
|
usage:
|
|
132
|
-
|
|
132
|
+
"Set WebSocket idle timeout in seconds to reproduce AWS limits (https://docs.aws.amazon.com/apigateway/latest/developerguide/limits.html#apigateway-execution-service-websocket-limits-table). Default: 600 (10 minutes).",
|
|
133
133
|
},
|
|
134
134
|
websocketPort: {
|
|
135
|
-
type:
|
|
136
|
-
usage:
|
|
135
|
+
type: "string",
|
|
136
|
+
usage: "Websocket port to listen on. Default: 3001.",
|
|
137
137
|
},
|
|
138
138
|
}
|
package/src/config/constants.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// dummy placeholder url for the WHATWG URL constructor
|
|
2
2
|
// https://github.com/nodejs/node/issues/12682
|
|
3
|
-
export const BASE_URL_PLACEHOLDER =
|
|
3
|
+
export const BASE_URL_PLACEHOLDER = "http://example"
|
|
4
4
|
|
|
5
|
-
export const CUSTOM_OPTION =
|
|
5
|
+
export const CUSTOM_OPTION = "serverless-offline"
|
|
6
6
|
|
|
7
|
-
export const DEFAULT_LAMBDA_RUNTIME =
|
|
7
|
+
export const DEFAULT_LAMBDA_RUNTIME = "nodejs14.x"
|
|
8
8
|
|
|
9
9
|
// https://docs.aws.amazon.com/lambda/latest/dg/limits.html
|
|
10
10
|
export const DEFAULT_LAMBDA_MEMORY_SIZE = 1024
|
|
@@ -15,8 +15,8 @@ export const DEFAULT_LAMBDA_TIMEOUT = 6 // 6 seconds
|
|
|
15
15
|
export const SERVER_SHUTDOWN_TIMEOUT = 5000
|
|
16
16
|
|
|
17
17
|
export const DEFAULT_WEBSOCKETS_API_ROUTE_SELECTION_EXPRESSION =
|
|
18
|
-
|
|
18
|
+
"$request.body.action"
|
|
19
19
|
|
|
20
|
-
export const DEFAULT_WEBSOCKETS_ROUTE =
|
|
20
|
+
export const DEFAULT_WEBSOCKETS_ROUTE = "$default"
|
|
21
21
|
|
|
22
22
|
export const DEFAULT_DOCKER_CONTAINER_PORT = 9001
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
albPort: 3003,
|
|
3
|
-
corsAllowHeaders:
|
|
4
|
-
corsAllowOrigin:
|
|
3
|
+
corsAllowHeaders: "accept,content-type,x-api-key,authorization",
|
|
4
|
+
corsAllowOrigin: "*",
|
|
5
5
|
corsDisallowCredentials: true,
|
|
6
|
-
corsExposedHeaders:
|
|
6
|
+
corsExposedHeaders: "WWW-Authenticate,Server-Authorization",
|
|
7
7
|
disableCookieValidation: false,
|
|
8
|
-
dockerHost:
|
|
8
|
+
dockerHost: "localhost",
|
|
9
9
|
dockerHostServicePath: null,
|
|
10
10
|
dockerNetwork: null,
|
|
11
11
|
dockerReadOnly: true,
|
|
12
12
|
enforceSecureCookies: false,
|
|
13
|
-
host:
|
|
13
|
+
host: "localhost",
|
|
14
14
|
httpPort: 3000,
|
|
15
15
|
httpsProtocol: null,
|
|
16
16
|
lambdaPort: 3002,
|
|
@@ -19,7 +19,7 @@ export default {
|
|
|
19
19
|
noAuth: false,
|
|
20
20
|
noPrependStageInUrl: false,
|
|
21
21
|
noTimeout: false,
|
|
22
|
-
prefix:
|
|
22
|
+
prefix: "",
|
|
23
23
|
reloadHandler: false,
|
|
24
24
|
resourceRoutes: false,
|
|
25
25
|
terminateIdleLambdaTime: 60,
|
package/src/config/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { default as commandOptions } from
|
|
2
|
-
export * from
|
|
3
|
-
export { default as defaultOptions } from
|
|
4
|
-
export * from
|
|
1
|
+
export { default as commandOptions } from "./commandOptions.js"
|
|
2
|
+
export * from "./constants.js"
|
|
3
|
+
export { default as defaultOptions } from "./defaultOptions.js"
|
|
4
|
+
export * from "./supportedRuntimes.js"
|