Skip to content

Commit

Permalink
fix(runtime): support default function (#1602)
Browse files Browse the repository at this point in the history
  • Loading branch information
skyoct committed Oct 23, 2023
1 parent f28abbe commit 04905dc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions runtimes/nodejs/src/handler/invoke.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Response } from 'express'
import { IRequest } from '../support/types'
import { INTERCEPTOR_FUNCTION_NAME } from '../constants'
import { DEFAULT_FUNCTION_NAME, INTERCEPTOR_FUNCTION_NAME } from '../constants'
import { parseToken } from '../support/token'
import { logger } from '../support/logger'
import {
Expand Down Expand Up @@ -56,9 +56,13 @@ async function invokeFunction(
isTrigger = true
}

const func = FunctionCache.getEngine(ctx.request.params?.name)
let func = FunctionCache.getEngine(ctx.request.params?.name)
if (!func) {
return ctx.response.status(404).send('Function Not Found')
console.log('not found')
func = FunctionCache.getEngine(DEFAULT_FUNCTION_NAME)
if (!func) {
return ctx.response.status(404).send('Function Not Found')
}
}
// reject while no HTTP enabled
if (
Expand Down

0 comments on commit 04905dc

Please sign in to comment.