@@ -7,13 +7,22 @@ import type { ImageConfigComplete, RemotePattern } from 'next/dist/shared/lib/im
7
7
import { outdent } from 'outdent'
8
8
import { join , relative , resolve } from 'pathe'
9
9
10
- import { HANDLER_FUNCTION_NAME , ODB_FUNCTION_NAME , IMAGE_FUNCTION_NAME , DEFAULT_FUNCTIONS_SRC } from '../constants'
10
+ import {
11
+ HANDLER_FUNCTION_NAME ,
12
+ ODB_FUNCTION_NAME ,
13
+ IMAGE_FUNCTION_NAME ,
14
+ DEFAULT_FUNCTIONS_SRC ,
15
+ HANDLER_FUNCTION_TITLE ,
16
+ ODB_FUNCTION_TITLE ,
17
+ IMAGE_FUNCTION_TITLE ,
18
+ } from '../constants'
11
19
import { getApiHandler } from '../templates/getApiHandler'
12
20
import { getHandler } from '../templates/getHandler'
13
21
import { getResolverForPages , getResolverForSourceFiles } from '../templates/getPageResolver'
14
22
15
23
import { ApiConfig , ApiRouteType , extractConfigFromFile } from './analysis'
16
24
import { getSourceFileForPage } from './files'
25
+ import { writeFunctionConfiguration } from './functionsMetaData'
17
26
import { getFunctionNameForPage } from './utils'
18
27
19
28
export interface ApiRouteConfig {
@@ -62,7 +71,7 @@ export const generateFunctions = async (
62
71
await writeFile ( join ( functionsDir , functionName , 'pages.js' ) , resolverSource )
63
72
}
64
73
65
- const writeHandler = async ( functionName : string , isODB : boolean ) => {
74
+ const writeHandler = async ( functionName : string , functionTitle : string , isODB : boolean ) => {
66
75
const handlerSource = await getHandler ( { isODB, publishDir, appDir : relative ( functionDir , appDir ) } )
67
76
await ensureDir ( join ( functionsDir , functionName ) )
68
77
await writeFile ( join ( functionsDir , functionName , `${ functionName } .js` ) , handlerSource )
@@ -71,10 +80,11 @@ export const generateFunctions = async (
71
80
join ( __dirname , '..' , '..' , 'lib' , 'templates' , 'handlerUtils.js' ) ,
72
81
join ( functionsDir , functionName , 'handlerUtils.js' ) ,
73
82
)
83
+ writeFunctionConfiguration ( functionName , functionTitle , functionsDir )
74
84
}
75
85
76
- await writeHandler ( HANDLER_FUNCTION_NAME , false )
77
- await writeHandler ( ODB_FUNCTION_NAME , true )
86
+ await writeHandler ( HANDLER_FUNCTION_NAME , HANDLER_FUNCTION_TITLE , false )
87
+ await writeHandler ( ODB_FUNCTION_NAME , ODB_FUNCTION_TITLE , true )
78
88
}
79
89
80
90
/**
@@ -138,6 +148,7 @@ export const setupImageFunction = async ({
138
148
} )
139
149
140
150
await copyFile ( join ( __dirname , '..' , '..' , 'lib' , 'templates' , 'ipx.js' ) , join ( functionDirectory , functionName ) )
151
+ writeFunctionConfiguration ( functionName . replace ( '.js' , '' ) , IMAGE_FUNCTION_TITLE , functionsPath )
141
152
142
153
// If we have edge functions then the request will have already been rewritten
143
154
// so this won't match. This is matched if edge is disabled or unavailable.
0 commit comments