Skip to content

Commit 2789098

Browse files
committed
Avoid exposing both promise and callback interface
1 parent 4fd6f7b commit 2789098

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/index.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export interface Options {
117117
* Create a server for handling AWS Lambda requests.
118118
*/
119119
export function createHandler (app: App, options: Options = {}) {
120-
return function (event: Event, context: Context, cb: (err: Error | null, res: Result) => void): Promise<void> {
120+
return function (event: Event, context: Context, cb: (err: Error | null, res: Result) => void): void {
121121
const { httpMethod: method } = event
122122
const url = format({ pathname: event.path, query: event.queryStringParameters })
123123
const isBinary = options.isBinary || (() => false)
@@ -171,11 +171,10 @@ export function createHandler (app: App, options: Options = {}) {
171171
req.finished = true
172172
req.bytesTransferred = rawBody ? rawBody.byteLength : 0
173173

174-
return Promise.resolve(app(req, finalhandler(req)))
175-
.then(
176-
(res) => sendResponse(res),
177-
(err) => sendResponse(mapError(err))
178-
)
174+
Promise.resolve(app(req, finalhandler(req))).then(
175+
(res) => sendResponse(res),
176+
(err) => sendResponse(mapError(err))
177+
)
179178
}
180179
}
181180

0 commit comments

Comments
 (0)