Skip to content

Commit 673dfc0

Browse files
committed
chore: created a separate function for getting extended API routes and their configs
1 parent ca48537 commit 673dfc0

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

packages/runtime/src/helpers/functions.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,26 @@ export const setupImageFunction = async ({
165165
}
166166

167167
/**
168-
* Look for extended API routes (background and scheduled functions) and extract the config from the source file.
168+
* Look for API routes, and extract the config from the source file.
169169
*/
170-
export const getExtendedApiRouteConfigs = async (publish: string, baseDir: string): Promise<Array<ApiRouteConfig>> => {
170+
export const getApiRouteConfigs = async (publish: string, baseDir: string): Promise<Array<ApiRouteConfig>> => {
171171
const pages = await readJSON(join(publish, 'server', 'pages-manifest.json'))
172172
const apiRoutes = Object.keys(pages).filter((page) => page.startsWith('/api/'))
173173
const pagesDir = join(baseDir, 'pages')
174174

175-
const settledApiRoutes = await Promise.all(
175+
return await Promise.all(
176176
apiRoutes.map(async (apiRoute) => {
177177
const filePath = getSourceFileForPage(apiRoute, pagesDir)
178178
return { route: apiRoute, config: await extractConfigFromFile(filePath), compiled: pages[apiRoute] }
179179
}),
180180
)
181+
}
182+
183+
/**
184+
* Looks for extended API routes (background and scheduled functions) and extract the config from the source file.
185+
*/
186+
export const getExtendedApiRouteConfigs = async (publish: string, baseDir: string): Promise<Array<ApiRouteConfig>> => {
187+
const settledApiRoutes = await getApiRouteConfigs(publish, baseDir)
181188

182189
// We only want to return the API routes that are background or scheduled functions
183190
return settledApiRoutes.filter((apiRoute) => apiRoute.config.type !== undefined)

0 commit comments

Comments
 (0)