@@ -31,17 +31,18 @@ type Mutable<T> = {
31
31
- readonly [ K in keyof T ] : T [ K ]
32
32
}
33
33
34
+ type MakeHandlerParams = {
35
+ conf : NextConfig
36
+ app : string
37
+ pageRoot : string
38
+ NextServer : NextServerType
39
+ staticManifest : Array < [ string , string ] >
40
+ mode : 'ssr' | 'odb'
41
+ }
42
+
34
43
// We return a function and then call `toString()` on it to serialise it as the launcher function
35
44
// eslint-disable-next-line max-lines-per-function
36
- const makeHandler = (
37
- conf : NextConfig ,
38
- app : string ,
39
- pageRoot ,
40
- NextServer : NextServerType ,
41
- staticManifest : Array < [ string , string ] > = [ ] ,
42
- mode = 'ssr' ,
43
- // eslint-disable-next-line max-params
44
- ) => {
45
+ const makeHandler = ( { conf, app, pageRoot, NextServer, staticManifest = [ ] , mode = 'ssr' } : MakeHandlerParams ) => {
45
46
// Change working directory into the site root, unless using Nx, which moves the
46
47
// dist directory and handles this itself
47
48
const dir = path . resolve ( __dirname , app )
@@ -117,7 +118,7 @@ const makeHandler = (
117
118
}
118
119
119
120
return async function handler ( event : HandlerEvent , context : HandlerContext ) {
120
- let requestMode = mode
121
+ let requestMode : string = mode
121
122
const prefetchResponse = getPrefetchResponse ( event , mode )
122
123
if ( prefetchResponse ) {
123
124
return prefetchResponse
@@ -220,7 +221,7 @@ export const getHandler = ({
220
221
const pageRoot = path . resolve ( path . join ( __dirname , "${ publishDir } " , "server" ) ) ;
221
222
exports . handler = ${
222
223
isODB
223
- ? `builder((${ makeHandler . toString ( ) } )(config, "${ appDir } ", pageRoot, NextServer, staticManifest, 'odb'));`
224
- : `(${ makeHandler . toString ( ) } )(config, "${ appDir } ", pageRoot, NextServer, staticManifest, 'ssr');`
224
+ ? `builder((${ makeHandler . toString ( ) } )({ conf: config, app: "${ appDir } ", pageRoot, NextServer, staticManifest, mode: 'odb' } ));`
225
+ : `(${ makeHandler . toString ( ) } )({ conf: config, app: "${ appDir } ", pageRoot, NextServer, staticManifest, mode: 'ssr' } );`
225
226
}
226
227
`
0 commit comments