Skip to content
This repository was archived by the owner on Jun 9, 2025. It is now read-only.

Commit b4154d7

Browse files
fix: use correct parameters in callback syntax (#4)
* fix: use correct parameters in callback syntax * chore: fix eslint paths
1 parent 9cc96c3 commit b4154d7

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"test:ci:ava": "nyc -r lcovonly -r text -r json ava"
2626
},
2727
"config": {
28-
"eslint": "--ignore-pattern 'README.md' --ignore-path .gitignore --cache --format=codeframe --max-warnings=0 \"{src,scripts,.github}/**/*.{js,md,html}\" \"*.{js,md,html}\" \".*.{js,md,html}\"",
28+
"eslint": "--ignore-pattern README.md --ignore-path .gitignore --cache --format=codeframe --max-warnings=0 \"{src,scripts,.github}/**/*.{js,md,html}\" \"*.{js,md,html}\" \".*.{js,md,html}\"",
2929
"prettier": "--ignore-path .gitignore --loglevel=warn \"{src,scripts,.github}/**/*.{js,md,yml,json,html}\" \"*.{js,yml,json,html}\" \".*.{js,yml,json,html}\" \"!**/package-lock.json\" \"!package-lock.json\""
3030
},
3131
"ava": {

src/lib/builder_functions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const wrapHandler = (handler) => async (event, context, callback) => {
2121
}
2222

2323
// eslint-disable-next-line promise/prefer-await-to-callbacks
24-
const wrappedCallback = (response) => callback(augmentResponse(response))
24+
const wrappedCallback = (error, response) => callback(error, augmentResponse(response))
2525
const response = await handler(event, context, wrappedCallback)
2626

2727
return augmentResponse(response)

test/builder_functions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ test('Injects the metadata object into a synchronous handler', async (t) => {
3131
statusCode: 200,
3232
}
3333
const myHandler = (event, context, callback) => {
34-
callback(originalResponse)
34+
callback(null, originalResponse)
3535
}
3636
const response = await invokeLambda(builderFunction(myHandler))
3737

test/helpers/main.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@ const invokeLambda = (handler, { method = 'GET' } = {}) => {
33
httpMethod: method,
44
}
55

6-
return new Promise((resolve) => {
7-
resolve(handler(event, {}, resolve))
6+
return new Promise((resolve, reject) => {
7+
const callback = (error, response) => {
8+
if (error) {
9+
reject(error)
10+
} else {
11+
resolve(response)
12+
}
13+
}
14+
15+
resolve(handler(event, {}, callback))
816
})
917
}
1018

0 commit comments

Comments
 (0)