serverless-offline 13.3.2 → 13.3.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.
Files changed (112) hide show
  1. package/README.md +17 -17
  2. package/package.json +19 -17
  3. package/src/ServerlessOffline.js +42 -42
  4. package/src/config/colors.js +9 -9
  5. package/src/config/commandOptions.js +61 -61
  6. package/src/config/constants.js +5 -5
  7. package/src/config/defaultOptions.js +6 -6
  8. package/src/config/index.js +4 -4
  9. package/src/config/supportedRuntimes.js +18 -18
  10. package/src/errors/index.js +1 -1
  11. package/src/events/alb/Alb.js +2 -2
  12. package/src/events/alb/AlbEventDefinition.js +2 -2
  13. package/src/events/alb/HttpServer.js +54 -54
  14. package/src/events/alb/index.js +1 -1
  15. package/src/events/alb/lambda-events/LambdaAlbRequestEvent.js +2 -2
  16. package/src/events/alb/lambda-events/index.js +1 -1
  17. package/src/events/authCanExecuteResource.js +3 -3
  18. package/src/events/authFunctionNameExtractor.js +9 -9
  19. package/src/events/authMatchPolicyResource.js +8 -8
  20. package/src/events/authValidateContext.js +11 -11
  21. package/src/events/http/Endpoint.js +26 -26
  22. package/src/events/http/Http.js +2 -2
  23. package/src/events/http/HttpEventDefinition.js +2 -2
  24. package/src/events/http/HttpServer.js +157 -158
  25. package/src/events/http/OfflineEndpoint.js +7 -7
  26. package/src/events/http/authJWTSettingsExtractor.js +2 -2
  27. package/src/events/http/createAuthScheme.js +29 -27
  28. package/src/events/http/createJWTAuthScheme.js +12 -12
  29. package/src/events/http/index.js +1 -1
  30. package/src/events/http/javaHelpers.js +2 -2
  31. package/src/events/http/lambda-events/LambdaIntegrationEvent.js +5 -5
  32. package/src/events/http/lambda-events/LambdaProxyIntegrationEvent.js +47 -47
  33. package/src/events/http/lambda-events/LambdaProxyIntegrationEventV2.js +27 -27
  34. package/src/events/http/lambda-events/VelocityContext.js +28 -32
  35. package/src/events/http/lambda-events/index.js +4 -4
  36. package/src/events/http/lambda-events/renderVelocityTemplateObject.js +13 -13
  37. package/src/events/http/parseResources.js +6 -6
  38. package/src/events/http/payloadSchemaValidator.js +2 -2
  39. package/src/events/schedule/Schedule.js +21 -21
  40. package/src/events/schedule/ScheduleEvent.js +7 -7
  41. package/src/events/schedule/ScheduleEventDefinition.js +1 -1
  42. package/src/events/schedule/index.js +1 -1
  43. package/src/events/websocket/HttpServer.js +9 -9
  44. package/src/events/websocket/WebSocket.js +4 -4
  45. package/src/events/websocket/WebSocketClients.js +29 -29
  46. package/src/events/websocket/WebSocketEventDefinition.js +1 -1
  47. package/src/events/websocket/WebSocketServer.js +9 -9
  48. package/src/events/websocket/http-routes/_catchAll/catchAllRoute.js +3 -3
  49. package/src/events/websocket/http-routes/_catchAll/index.js +1 -1
  50. package/src/events/websocket/http-routes/connections/ConnectionsController.js +1 -1
  51. package/src/events/websocket/http-routes/connections/connectionsRoutes.js +6 -6
  52. package/src/events/websocket/http-routes/connections/index.js +1 -1
  53. package/src/events/websocket/http-routes/index.js +2 -2
  54. package/src/events/websocket/index.js +1 -1
  55. package/src/events/websocket/lambda-events/WebSocketAuthorizerEvent.js +5 -5
  56. package/src/events/websocket/lambda-events/WebSocketConnectEvent.js +7 -6
  57. package/src/events/websocket/lambda-events/WebSocketDisconnectEvent.js +5 -5
  58. package/src/events/websocket/lambda-events/WebSocketEvent.js +2 -2
  59. package/src/events/websocket/lambda-events/WebSocketRequestContext.js +12 -11
  60. package/src/events/websocket/lambda-events/index.js +4 -4
  61. package/src/index.js +1 -1
  62. package/src/lambda/HttpServer.js +11 -11
  63. package/src/lambda/Lambda.js +2 -2
  64. package/src/lambda/LambdaContext.js +1 -1
  65. package/src/lambda/LambdaFunction.js +34 -34
  66. package/src/lambda/LambdaFunctionPool.js +3 -3
  67. package/src/lambda/handler-runner/HandlerRunner.js +12 -12
  68. package/src/lambda/handler-runner/docker-runner/DockerContainer.js +59 -59
  69. package/src/lambda/handler-runner/docker-runner/DockerImage.js +6 -6
  70. package/src/lambda/handler-runner/docker-runner/DockerRunner.js +2 -2
  71. package/src/lambda/handler-runner/docker-runner/index.js +1 -1
  72. package/src/lambda/handler-runner/go-runner/GoRunner.js +34 -34
  73. package/src/lambda/handler-runner/go-runner/index.js +1 -1
  74. package/src/lambda/handler-runner/in-process-runner/InProcessRunner.js +7 -7
  75. package/src/lambda/handler-runner/in-process-runner/aws-lambda-ric/UserFunction.js +52 -52
  76. package/src/lambda/handler-runner/in-process-runner/index.js +1 -1
  77. package/src/lambda/handler-runner/index.js +1 -1
  78. package/src/lambda/handler-runner/java-runner/JavaRunner.js +13 -13
  79. package/src/lambda/handler-runner/java-runner/index.js +1 -1
  80. package/src/lambda/handler-runner/python-runner/PythonRunner.js +21 -21
  81. package/src/lambda/handler-runner/python-runner/index.js +1 -1
  82. package/src/lambda/handler-runner/ruby-runner/RubyRunner.js +11 -11
  83. package/src/lambda/handler-runner/ruby-runner/index.js +1 -1
  84. package/src/lambda/handler-runner/worker-thread-runner/WorkerThreadRunner.js +6 -6
  85. package/src/lambda/handler-runner/worker-thread-runner/index.js +1 -1
  86. package/src/lambda/handler-runner/worker-thread-runner/workerThreadHelper.js +4 -4
  87. package/src/lambda/index.js +1 -1
  88. package/src/lambda/routes/index.js +2 -2
  89. package/src/lambda/routes/invocations/InvocationsController.js +11 -11
  90. package/src/lambda/routes/invocations/index.js +1 -1
  91. package/src/lambda/routes/invocations/invocationsRoute.js +15 -15
  92. package/src/lambda/routes/invoke-async/index.js +1 -1
  93. package/src/lambda/routes/invoke-async/invokeAsyncRoute.js +6 -6
  94. package/src/utils/checkDockerDaemon.js +8 -8
  95. package/src/utils/checkGoVersion.js +3 -3
  96. package/src/utils/createApiKey.js +2 -2
  97. package/src/utils/detectExecutable.js +2 -2
  98. package/src/utils/formatToClfTime.js +2 -2
  99. package/src/utils/generateHapiPath.js +8 -8
  100. package/src/utils/getApiKeysValues.js +2 -2
  101. package/src/utils/getHttpApiCorsConfig.js +11 -11
  102. package/src/utils/getRawQueryParams.js +2 -2
  103. package/src/utils/index.js +25 -26
  104. package/src/utils/jsonPath.js +1 -1
  105. package/src/utils/logRoutes.js +13 -13
  106. package/src/utils/parseHeaders.js +1 -1
  107. package/src/utils/parseMultiValueHeaders.js +1 -1
  108. package/src/utils/parseMultiValueQueryStringParameters.js +1 -1
  109. package/src/utils/parseQueryStringParameters.js +1 -1
  110. package/src/utils/parseQueryStringParametersForPayloadV2.js +1 -1
  111. package/src/utils/splitHandlerPathAndName.js +3 -3
  112. package/src/utils/createUniqueId.js +0 -5
@@ -1,16 +1,16 @@
1
- import { EOL, platform } from 'node:os'
2
- import { relative } from 'node:path'
3
- import { cwd } from 'node:process'
4
- import { log } from '@serverless/utils/log.js'
5
- import { join } from 'desm'
6
- import { execa } from 'execa'
7
- import { splitHandlerPathAndName } from '../../../utils/index.js'
1
+ import { EOL, platform } from "node:os"
2
+ import { relative } from "node:path"
3
+ import { cwd } from "node:process"
4
+ import { log } from "@serverless/utils/log.js"
5
+ import { join } from "desm"
6
+ import { execa } from "execa"
7
+ import { splitHandlerPathAndName } from "../../../utils/index.js"
8
8
 
9
9
  const { parse, stringify } = JSON
10
10
  const { hasOwn } = Object
11
11
 
12
12
  export default class RubyRunner {
13
- static #payloadIdentifier = '__offline_payload__'
13
+ static #payloadIdentifier = "__offline_payload__"
14
14
 
15
15
  #env = null
16
16
 
@@ -49,7 +49,7 @@ export default class RubyRunner {
49
49
  // now let's see if we have a property __offline_payload__
50
50
  if (
51
51
  json &&
52
- typeof json === 'object' &&
52
+ typeof json === "object" &&
53
53
  hasOwn(json, RubyRunner.#payloadIdentifier)
54
54
  ) {
55
55
  payload = json[RubyRunner.#payloadIdentifier]
@@ -66,7 +66,7 @@ export default class RubyRunner {
66
66
  // invoke.rb, copy/pasted entirely as is:
67
67
  // https://github.com/serverless/serverless/blob/v1.50.0/lib/plugins/aws/invokeLocal/invoke.rb
68
68
  async run(event, context) {
69
- const runtime = platform() === 'win32' ? 'ruby.exe' : 'ruby'
69
+ const runtime = platform() === "win32" ? "ruby.exe" : "ruby"
70
70
 
71
71
  // https://docs.aws.amazon.com/lambda/latest/dg/ruby-context.html
72
72
 
@@ -84,7 +84,7 @@ export default class RubyRunner {
84
84
  const { stderr, stdout } = await execa(
85
85
  runtime,
86
86
  [
87
- join(import.meta.url, 'invoke.rb'),
87
+ join(import.meta.url, "invoke.rb"),
88
88
  relative(cwd(), this.#handlerPath),
89
89
  this.#handlerName,
90
90
  ],
@@ -1 +1 @@
1
- export { default } from './RubyRunner.js'
1
+ export { default } from "./RubyRunner.js"
@@ -1,5 +1,5 @@
1
- import { MessageChannel, Worker } from 'node:worker_threads'
2
- import { join } from 'desm'
1
+ import { MessageChannel, Worker } from "node:worker_threads"
2
+ import { join } from "desm"
3
3
 
4
4
  export default class WorkerThreadRunner {
5
5
  #workerThread = null
@@ -8,7 +8,7 @@ export default class WorkerThreadRunner {
8
8
  const { codeDir, functionKey, handler, servicePath, timeout } = funOptions
9
9
 
10
10
  this.#workerThread = new Worker(
11
- join(import.meta.url, 'workerThreadHelper.js'),
11
+ join(import.meta.url, "workerThreadHelper.js"),
12
12
  {
13
13
  // don't pass process.env from the main process!
14
14
  env,
@@ -35,7 +35,7 @@ export default class WorkerThreadRunner {
35
35
  const { port1, port2 } = new MessageChannel()
36
36
 
37
37
  port1
38
- .on('message', (value) => {
38
+ .on("message", (value) => {
39
39
  if (value instanceof Error) {
40
40
  rej(value)
41
41
  return
@@ -45,9 +45,9 @@ export default class WorkerThreadRunner {
45
45
  })
46
46
  // emitted if the worker thread throws an uncaught exception.
47
47
  // In that case, the worker will be terminated.
48
- .on('error', rej)
48
+ .on("error", rej)
49
49
  // TODO
50
- .on('exit', (code) => {
50
+ .on("exit", (code) => {
51
51
  if (code !== 0) {
52
52
  rej(new Error(`Worker stopped with exit code ${code}`))
53
53
  }
@@ -1 +1 @@
1
- export { default } from './WorkerThreadRunner.js'
1
+ export { default } from "./WorkerThreadRunner.js"
@@ -1,6 +1,6 @@
1
- import { env } from 'node:process'
2
- import { parentPort, workerData } from 'node:worker_threads'
3
- import InProcessRunner from '../in-process-runner/index.js'
1
+ import { env } from "node:process"
2
+ import { parentPort, workerData } from "node:worker_threads"
3
+ import InProcessRunner from "../in-process-runner/index.js"
4
4
 
5
5
  const { codeDir, functionKey, handler, servicePath, timeout } = workerData
6
6
 
@@ -15,7 +15,7 @@ const inProcessRunner = new InProcessRunner(
15
15
  env,
16
16
  )
17
17
 
18
- parentPort.on('message', async (messageData) => {
18
+ parentPort.on("message", async (messageData) => {
19
19
  const { context, event, port } = messageData
20
20
 
21
21
  let result
@@ -1 +1 @@
1
- export { default } from './Lambda.js'
1
+ export { default } from "./Lambda.js"
@@ -1,2 +1,2 @@
1
- export { default as invocationsRoute } from './invocations/index.js'
2
- export { default as invokeAsyncRoute } from './invoke-async/index.js'
1
+ export { default as invocationsRoute } from "./invocations/index.js"
2
+ export { default as invokeAsyncRoute } from "./invoke-async/index.js"
@@ -1,4 +1,4 @@
1
- import { log } from '@serverless/utils/log.js'
1
+ import { log } from "@serverless/utils/log.js"
2
2
 
3
3
  export default class InvocationsController {
4
4
  #lambda = null
@@ -17,10 +17,10 @@ export default class InvocationsController {
17
17
  // Conforms to the actual response from AWS Lambda when invoking a non-existent
18
18
  // function. Details on the error are provided in the Payload.Message key
19
19
  return {
20
- FunctionError: 'ResourceNotFoundException',
20
+ FunctionError: "ResourceNotFoundException",
21
21
  Payload: {
22
22
  Message: `Function not found: ${functionName}`,
23
- Type: 'User',
23
+ Type: "User",
24
24
  },
25
25
  StatusCode: 404,
26
26
  }
@@ -31,16 +31,16 @@ export default class InvocationsController {
31
31
  lambdaFunction.setClientContext(clientContext)
32
32
  lambdaFunction.setEvent(event)
33
33
 
34
- if (invocationType === 'Event') {
34
+ if (invocationType === "Event") {
35
35
  // don't await result!
36
36
  lambdaFunction.runHandler()
37
37
  return {
38
- Payload: '',
38
+ Payload: "",
39
39
  StatusCode: 202,
40
40
  }
41
41
  }
42
42
 
43
- if (!invocationType || invocationType === 'RequestResponse') {
43
+ if (!invocationType || invocationType === "RequestResponse") {
44
44
  let result
45
45
 
46
46
  try {
@@ -57,8 +57,8 @@ export default class InvocationsController {
57
57
  return {
58
58
  Payload: {
59
59
  errorMessage: err.message,
60
- errorType: 'Error',
61
- trace: err.stack.split('\n'),
60
+ errorType: "Error",
61
+ trace: err.stack.split("\n"),
62
62
  },
63
63
  StatusCode: 200,
64
64
  UnhandledError: true,
@@ -70,7 +70,7 @@ 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 && typeof result === 'string') {
73
+ if (result && typeof result === "string") {
74
74
  result = `"${result}"`
75
75
  }
76
76
 
@@ -89,10 +89,10 @@ export default class InvocationsController {
89
89
  log.error(errMsg)
90
90
 
91
91
  return {
92
- FunctionError: 'InvalidParameterValueException',
92
+ FunctionError: "InvalidParameterValueException",
93
93
  Payload: {
94
94
  Message: errMsg,
95
- Type: 'User',
95
+ Type: "User",
96
96
  },
97
97
  StatusCode: 400,
98
98
  }
@@ -1 +1 @@
1
- export { default } from './invocationsRoute.js'
1
+ export { default } from "./invocationsRoute.js"
@@ -1,5 +1,5 @@
1
- import { Buffer } from 'node:buffer'
2
- import InvocationsController from './InvocationsController.js'
1
+ import { Buffer } from "node:buffer"
2
+ import InvocationsController from "./InvocationsController.js"
3
3
 
4
4
  const { parse } = JSON
5
5
 
@@ -16,20 +16,20 @@ export default function invocationsRoute(lambda, options) {
16
16
  } = request
17
17
 
18
18
  const parsedHeaders = new Headers(headers)
19
- const clientContextHeader = parsedHeaders.get('x-amz-client-context')
20
- const invocationType = parsedHeaders.get('x-amz-invocation-type')
19
+ const clientContextHeader = parsedHeaders.get("x-amz-client-context")
20
+ const invocationType = parsedHeaders.get("x-amz-invocation-type")
21
21
 
22
22
  // default is undefined
23
23
  let clientContext
24
24
 
25
25
  // check client context header was set
26
26
  if (clientContextHeader) {
27
- const clientContextBuffer = Buffer.from(clientContextHeader, 'base64')
28
- clientContext = parse(clientContextBuffer.toString('utf8'))
27
+ const clientContextBuffer = Buffer.from(clientContextHeader, "base64")
28
+ clientContext = parse(clientContextBuffer.toString("utf8"))
29
29
  }
30
30
 
31
31
  // check if payload was set, if not, default event is an empty object
32
- const event = payload.length > 0 ? parse(payload.toString('utf8')) : {}
32
+ const event = payload.length > 0 ? parse(payload.toString("utf8")) : {}
33
33
 
34
34
  const invokeResults = await invocationsController.invoke(
35
35
  functionName,
@@ -39,12 +39,12 @@ export default function invocationsRoute(lambda, options) {
39
39
  )
40
40
 
41
41
  // Return with correct status codes
42
- let resultPayload = ''
42
+ let resultPayload = ""
43
43
  let statusCode = 200
44
44
  let functionError = null
45
45
  if (invokeResults) {
46
46
  const isPayloadDefined = invokeResults.Payload !== undefined
47
- resultPayload = isPayloadDefined ? invokeResults.Payload : ''
47
+ resultPayload = isPayloadDefined ? invokeResults.Payload : ""
48
48
  statusCode = invokeResults.StatusCode || 200
49
49
  functionError = invokeResults.FunctionError || null
50
50
  }
@@ -52,26 +52,26 @@ export default function invocationsRoute(lambda, options) {
52
52
  if (functionError) {
53
53
  // AWS Invoke documentation is wrong. The header for error type is
54
54
  // 'x-amzn-ErrorType' in production, not 'X-Amz-Function-Error'
55
- response.header('x-amzn-ErrorType', functionError)
55
+ response.header("x-amzn-ErrorType", functionError)
56
56
  }
57
57
  if (invokeResults && invokeResults.UnhandledError) {
58
- response.header('X-Amz-Function-Error', 'Unhandled')
58
+ response.header("X-Amz-Function-Error", "Unhandled")
59
59
  }
60
60
  return response
61
61
  },
62
- method: 'POST',
62
+ method: "POST",
63
63
  options: {
64
64
  cors: options.corsConfig,
65
65
  payload: {
66
66
  // allow: ['binary/octet-stream'],
67
- defaultContentType: 'binary/octet-stream',
67
+ defaultContentType: "binary/octet-stream",
68
68
  // Set maximum size to 6 MB to match maximum invocation payload size in synchronous responses
69
69
  maxBytes: 1024 * 1024 * 6,
70
70
  // request.payload will be a raw buffer
71
71
  parse: false,
72
72
  },
73
- tags: ['api'],
73
+ tags: ["api"],
74
74
  },
75
- path: '/2015-03-31/functions/{functionName}/invocations',
75
+ path: "/2015-03-31/functions/{functionName}/invocations",
76
76
  }
77
77
  }
@@ -1 +1 @@
1
- export { default } from './invokeAsyncRoute.js'
1
+ export { default } from "./invokeAsyncRoute.js"
@@ -1,4 +1,4 @@
1
- import InvokeAsyncController from './InvokeAsyncController.js'
1
+ import InvokeAsyncController from "./InvokeAsyncController.js"
2
2
 
3
3
  const { parse } = JSON
4
4
 
@@ -13,21 +13,21 @@ export default function invokeRoute(lambda, options) {
13
13
  payload,
14
14
  } = request
15
15
 
16
- const event = parse(payload.toString('utf8'))
16
+ const event = parse(payload.toString("utf8"))
17
17
 
18
18
  return invokeAsyncController.invokeAsync(functionName, event)
19
19
  },
20
- method: 'POST',
20
+ method: "POST",
21
21
  options: {
22
22
  cors: options.corsConfig,
23
23
  payload: {
24
24
  // allow: ['binary/octet-stream'],
25
- defaultContentType: 'binary/octet-stream',
25
+ defaultContentType: "binary/octet-stream",
26
26
  // request.payload will be a raw buffer
27
27
  parse: false,
28
28
  },
29
- tags: ['api'],
29
+ tags: ["api"],
30
30
  },
31
- path: '/2014-11-13/functions/{functionName}/invoke-async/',
31
+ path: "/2014-11-13/functions/{functionName}/invoke-async/",
32
32
  }
33
33
  }
@@ -1,19 +1,19 @@
1
- import { execa } from 'execa'
1
+ import { execa } from "execa"
2
2
 
3
3
  export default async function checkDockerDaemon() {
4
4
  let dockerServerOS
5
5
 
6
6
  try {
7
- ;({ stdout: dockerServerOS } = await execa('docker', [
8
- 'version',
9
- '--format',
10
- '{{.Server.Os}}',
7
+ ;({ stdout: dockerServerOS } = await execa("docker", [
8
+ "version",
9
+ "--format",
10
+ "{{.Server.Os}}",
11
11
  ]))
12
12
  } catch {
13
- throw new Error('The docker daemon is not running.')
13
+ throw new Error("The docker daemon is not running.")
14
14
  }
15
15
 
16
- if (dockerServerOS !== 'linux') {
17
- throw new Error('Please switch docker daemon to linux mode.')
16
+ if (dockerServerOS !== "linux") {
17
+ throw new Error("Please switch docker daemon to linux mode.")
18
18
  }
19
19
  }
@@ -1,12 +1,12 @@
1
- import { execa } from 'execa'
1
+ import { execa } from "execa"
2
2
 
3
3
  export default async function checkGoVersion() {
4
4
  let goVersion
5
5
 
6
6
  try {
7
- const { stdout } = await execa('go', ['version'])
7
+ const { stdout } = await execa("go", ["version"])
8
8
  if (/go1.\d+/g.test(stdout)) {
9
- goVersion = '1.x'
9
+ goVersion = "1.x"
10
10
  }
11
11
  } catch {
12
12
  // @ignore
@@ -1,5 +1,5 @@
1
- import { createHash } from 'node:crypto'
1
+ import { createHash } from "node:crypto"
2
2
 
3
3
  export default function createApiKey() {
4
- return createHash('md5').digest('hex')
4
+ return createHash("md5").digest("hex")
5
5
  }
@@ -1,6 +1,6 @@
1
- import { execa } from 'execa'
1
+ import { execa } from "execa"
2
2
 
3
- export default async function detectExecutable(exe, versionFlag = '--version') {
3
+ export default async function detectExecutable(exe, versionFlag = "--version") {
4
4
  try {
5
5
  const { failed } = await execa(exe, [versionFlag])
6
6
 
@@ -1,4 +1,4 @@
1
- import { DateTime } from 'luxon'
1
+ import { DateTime } from "luxon"
2
2
 
3
3
  const { fromMillis } = DateTime
4
4
 
@@ -13,5 +13,5 @@ const { fromMillis } = DateTime
13
13
  // second = 2*digit
14
14
  // zone = (`+' | `-') 4*digit
15
15
  export default function formatToClfTime(millis) {
16
- return fromMillis(millis).toFormat('dd/MMM/yyyy:HH:mm:ss ZZZ')
16
+ return fromMillis(millis).toFormat("dd/MMM/yyyy:HH:mm:ss ZZZ")
17
17
  }
@@ -1,5 +1,5 @@
1
1
  export default function generateHapiPath(path, options, serverless) {
2
- let hapiPath = path.startsWith('/') ? path : `/${path}`
2
+ let hapiPath = path.startsWith("/") ? path : `/${path}`
3
3
 
4
4
  if (!options.noPrependStageInUrl) {
5
5
  const stage = options.stage || serverless.service.provider.stage
@@ -11,18 +11,18 @@ export default function generateHapiPath(path, options, serverless) {
11
11
  hapiPath = `/${options.prefix}${hapiPath}`
12
12
  }
13
13
 
14
- if (hapiPath !== '/' && hapiPath.endsWith('/')) {
14
+ if (hapiPath !== "/" && hapiPath.endsWith("/")) {
15
15
  hapiPath = hapiPath.slice(0, -1)
16
16
  }
17
17
 
18
- hapiPath = hapiPath.replaceAll('+}', '*}')
18
+ hapiPath = hapiPath.replaceAll("+}", "*}")
19
19
 
20
20
  return hapiPath
21
21
  }
22
22
 
23
23
  export function generateAlbHapiPath(path, options, serverless) {
24
24
  // path must start with '/'
25
- let hapiPath = path.startsWith('/') ? path : `/${path}`
25
+ let hapiPath = path.startsWith("/") ? path : `/${path}`
26
26
 
27
27
  if (!options.noPrependStageInUrl) {
28
28
  const stage = options.stage || serverless.service.provider.stage
@@ -35,15 +35,15 @@ export function generateAlbHapiPath(path, options, serverless) {
35
35
  }
36
36
 
37
37
  if (
38
- hapiPath !== '/' &&
39
- hapiPath.endsWith('/') &&
38
+ hapiPath !== "/" &&
39
+ hapiPath.endsWith("/") &&
40
40
  !options.noStripTrailingSlashInUrl
41
41
  ) {
42
42
  hapiPath = hapiPath.slice(0, -1)
43
43
  }
44
44
 
45
- for (let i = 0; hapiPath.includes('*'); i += 1) {
46
- hapiPath = hapiPath.replace('*', `{${i}}`)
45
+ for (let i = 0; hapiPath.includes("*"); i += 1) {
46
+ hapiPath = hapiPath.replace("*", `{${i}}`)
47
47
  }
48
48
 
49
49
  return hapiPath
@@ -2,10 +2,10 @@ export default function getApiKeysValues(apiKeys) {
2
2
  return new Set(
3
3
  apiKeys
4
4
  .map((apiKey) => {
5
- if (typeof apiKey === 'object' && apiKey.value != null) {
5
+ if (typeof apiKey === "object" && apiKey.value != null) {
6
6
  return apiKey.value
7
7
  }
8
- if (typeof apiKey === 'string') {
8
+ if (typeof apiKey === "string") {
9
9
  return apiKey
10
10
  }
11
11
  return undefined
@@ -1,4 +1,4 @@
1
- import { log } from '@serverless/utils/log.js'
1
+ import { log } from "@serverless/utils/log.js"
2
2
 
3
3
  export default function getHttpApiCorsConfig(httpApiCors) {
4
4
  if (httpApiCors === true) {
@@ -6,23 +6,23 @@ export default function getHttpApiCorsConfig(httpApiCors) {
6
6
  // https://www.serverless.com/framework/docs/providers/aws/events/http-api/
7
7
  const c = {
8
8
  allowedHeaders: [
9
- 'Authorization',
10
- 'Content-Type',
11
- 'X-Amz-Date',
12
- 'X-Amz-Security-Token',
13
- 'X-Amz-User-Agent',
14
- 'X-Api-Key',
9
+ "Authorization",
10
+ "Content-Type",
11
+ "X-Amz-Date",
12
+ "X-Amz-Security-Token",
13
+ "X-Amz-User-Agent",
14
+ "X-Api-Key",
15
15
  ],
16
- allowedMethods: ['DELETE', 'GET', 'OPTIONS', 'PATCH', 'POST', 'PUT'],
17
- allowedOrigins: ['*'],
16
+ allowedMethods: ["DELETE", "GET", "OPTIONS", "PATCH", "POST", "PUT"],
17
+ allowedOrigins: ["*"],
18
18
  }
19
19
 
20
- log.debug('Using CORS policy', c)
20
+ log.debug("Using CORS policy", c)
21
21
 
22
22
  return c
23
23
  }
24
24
 
25
- log.debug('Using CORS policy', httpApiCors)
25
+ log.debug("Using CORS policy", httpApiCors)
26
26
 
27
27
  return httpApiCors
28
28
  }
@@ -1,4 +1,4 @@
1
- import parseQueryStringParameters from './parseQueryStringParameters.js'
1
+ import parseQueryStringParameters from "./parseQueryStringParameters.js"
2
2
 
3
3
  export default function getRawQueryParams(url) {
4
4
  const queryParams = parseQueryStringParameters(url) || {}
@@ -7,5 +7,5 @@ export default function getRawQueryParams(url) {
7
7
  accumulator.push(`${currentKey}=${queryParams[currentKey]}`)
8
8
  return accumulator
9
9
  }, [])
10
- .join('&')
10
+ .join("&")
11
11
  }
@@ -1,22 +1,21 @@
1
- export { default as checkDockerDaemon } from './checkDockerDaemon.js'
2
- export { default as checkGoVersion } from './checkGoVersion.js'
3
- export { default as createApiKey } from './createApiKey.js'
4
- export { default as createUniqueId } from './createUniqueId.js'
5
- export { default as detectExecutable } from './detectExecutable.js'
6
- export { default as formatToClfTime } from './formatToClfTime.js'
7
- export { default as generateHapiPath } from './generateHapiPath.js'
8
- export { default as getApiKeysValues } from './getApiKeysValues.js'
9
- export { default as getHttpApiCorsConfig } from './getHttpApiCorsConfig.js'
10
- export { default as getRawQueryParams } from './getRawQueryParams.js'
11
- export { default as jsonPath } from './jsonPath.js'
12
- export { default as lowerCaseKeys } from './lowerCaseKeys.js'
13
- export { default as parseHeaders } from './parseHeaders.js'
14
- export { default as parseMultiValueHeaders } from './parseMultiValueHeaders.js'
15
- export { default as parseMultiValueQueryStringParameters } from './parseMultiValueQueryStringParameters.js'
16
- export { default as parseQueryStringParameters } from './parseQueryStringParameters.js'
17
- export { default as parseQueryStringParametersForPayloadV2 } from './parseQueryStringParametersForPayloadV2.js'
18
- export { default as splitHandlerPathAndName } from './splitHandlerPathAndName.js'
19
- export { generateAlbHapiPath } from './generateHapiPath.js'
1
+ export { default as checkDockerDaemon } from "./checkDockerDaemon.js"
2
+ export { default as checkGoVersion } from "./checkGoVersion.js"
3
+ export { default as createApiKey } from "./createApiKey.js"
4
+ export { default as detectExecutable } from "./detectExecutable.js"
5
+ export { default as formatToClfTime } from "./formatToClfTime.js"
6
+ export { default as generateHapiPath } from "./generateHapiPath.js"
7
+ export { default as getApiKeysValues } from "./getApiKeysValues.js"
8
+ export { default as getHttpApiCorsConfig } from "./getHttpApiCorsConfig.js"
9
+ export { default as getRawQueryParams } from "./getRawQueryParams.js"
10
+ export { default as jsonPath } from "./jsonPath.js"
11
+ export { default as lowerCaseKeys } from "./lowerCaseKeys.js"
12
+ export { default as parseHeaders } from "./parseHeaders.js"
13
+ export { default as parseMultiValueHeaders } from "./parseMultiValueHeaders.js"
14
+ export { default as parseMultiValueQueryStringParameters } from "./parseMultiValueQueryStringParameters.js"
15
+ export { default as parseQueryStringParameters } from "./parseQueryStringParameters.js"
16
+ export { default as parseQueryStringParametersForPayloadV2 } from "./parseQueryStringParametersForPayloadV2.js"
17
+ export { default as splitHandlerPathAndName } from "./splitHandlerPathAndName.js"
18
+ export { generateAlbHapiPath } from "./generateHapiPath.js"
20
19
  // export { default as baseImage } from './baseImage.js'
21
20
 
22
21
  const { isArray } = Array
@@ -25,12 +24,12 @@ const { keys } = Object
25
24
  // Detect the toString encoding from the request headers content-type
26
25
  // enhance if further content types need to be non utf8 encoded.
27
26
  export function detectEncoding(request) {
28
- const contentType = request.headers['content-type']
27
+ const contentType = request.headers["content-type"]
29
28
 
30
- return typeof contentType === 'string' &&
31
- contentType.includes('multipart/form-data')
32
- ? 'binary'
33
- : 'utf8'
29
+ return typeof contentType === "string" &&
30
+ contentType.includes("multipart/form-data")
31
+ ? "binary"
32
+ : "utf8"
34
33
  }
35
34
 
36
35
  export function nullIfEmpty(obj) {
@@ -38,9 +37,9 @@ export function nullIfEmpty(obj) {
38
37
  }
39
38
 
40
39
  export function isPlainObject(obj) {
41
- return typeof obj === 'object' && !isArray(obj) && obj != null
40
+ return typeof obj === "object" && !isArray(obj) && obj != null
42
41
  }
43
42
 
44
43
  export function toPlainOrEmptyObject(obj) {
45
- return typeof obj === 'object' && !isArray(obj) ? obj : {}
44
+ return typeof obj === "object" && !isArray(obj) ? obj : {}
46
45
  }
@@ -1,4 +1,4 @@
1
- import { JSONPath } from 'jsonpath-plus'
1
+ import { JSONPath } from "jsonpath-plus"
2
2
 
3
3
  export default function jsonPath(json, path) {
4
4
  // NOTE: JSONPath returns undefined if 'json' is e.g. null, undefined, string,