Skip to content

Commit

Permalink
refactor: make payload identifier private static
Browse files Browse the repository at this point in the history
  • Loading branch information
dnalborczyk committed Jul 30, 2022
1 parent 4648d39 commit 7d4bf76
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/lambda/handler-runner/java-runner/JavaRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const { parse, stringify } = JSON
const { hasOwn } = Object

export default class JavaRunner {
static #payloadIdentifier = '__offline_payload__'

#deployPackage = null

#env = null
Expand Down Expand Up @@ -45,9 +47,9 @@ export default class JavaRunner {
if (
json &&
typeof json === 'object' &&
hasOwn(json, '__offline_payload__')
hasOwn(json, JavaRunner.#payloadIdentifier)
) {
return json.__offline_payload__
return json[JavaRunner.#payloadIdentifier]
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/lambda/handler-runner/python-runner/PythonRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const { assign, hasOwn } = Object
const __dirname = dirname(fileURLToPath(import.meta.url))

export default class PythonRunner {
static #payloadIdentifier = '__offline_payload__'

#env = null

#handlerName = null
Expand Down Expand Up @@ -82,9 +84,9 @@ export default class PythonRunner {
if (
json &&
typeof json === 'object' &&
hasOwn(json, '__offline_payload__')
hasOwn(json, PythonRunner.#payloadIdentifier)
) {
payload = json.__offline_payload__
payload = json[PythonRunner.#payloadIdentifier]
// everything else is print(), logging, ...
} else {
log.notice(item)
Expand Down
6 changes: 4 additions & 2 deletions src/lambda/handler-runner/ruby-runner/RubyRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const { hasOwn } = Object
const __dirname = dirname(fileURLToPath(import.meta.url))

export default class RubyRunner {
static #payloadIdentifier = '__offline_payload__'

#env = null

#handlerName = null
Expand Down Expand Up @@ -47,9 +49,9 @@ export default class RubyRunner {
if (
json &&
typeof json === 'object' &&
hasOwn(json, '__offline_payload__')
hasOwn(json, RubyRunner.#payloadIdentifier)
) {
payload = json.__offline_payload__
payload = json[RubyRunner.#payloadIdentifier]
} else {
log.notice(item)
}
Expand Down

0 comments on commit 7d4bf76

Please sign in to comment.