Skip to content

Commit ac302f9

Browse files
committed
review: move appInstance initialization out of function scope so it occurs during lambda init (rather than execution)
1 parent a09d37a commit ac302f9

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/lambdas/api/index.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const {
3030
* @typedef {z.infer<typeof LambdaErrorSchema>} LambdaError
3131
*/
3232

33+
const appInstance = await createApp()
34+
3335
/** @type {APIGatewayProxyResult} */
3436
const internalServerError = Object.freeze({
3537
statusCode: 500,
@@ -156,18 +158,12 @@ const invokePostHook = async (lambda, postHook, payload) => {
156158
return hookResult
157159
}
158160

159-
let appInstance = null
160-
161161
/**
162162
* @param {APIGatewayProxyEvent} event
163163
* @param {Context} context
164164
* @returns {Promise<APIGatewayProxyResult>}
165165
*/
166166
const callServerlessApp = async (event, context) => {
167-
if (!appInstance) {
168-
appInstance = await createApp()
169-
}
170-
171167
const result = await serverless(appInstance)(event, context)
172168

173169
try {

0 commit comments

Comments
 (0)