import type { RequestListener } from 'http' ; const startTime = process . hrtime ( ) ; let nuxtConfig ; const loaders = [ { name : 'jiti' , args : [ ] } , { name : 'esm' , args : [ module , { cjs : { dedefault : true } } ] } ] ; for ( const { name , args } of loaders ) { try { const load = require ( name ) ( ... args ) ; const config = load ( '__NUXT_CONFIG__' ) ; nuxtConfig = config . default || config ; break ; } catch ( err ) { if ( name === 'esm' ) { throw new Error ( `Could not load Nuxt configuration. Make sure all dependencies are listed in package.json dependencies or in serverFiles within builder options:\n ${ err }` ) ; } } } const { Nuxt } = require ( '@nuxt/core__NUXT_SUFFIX__' ) ; const nuxt = new Nuxt ( { _start : true , ... nuxtConfig } ) ; let isReady = false ; const readyPromise = nuxt . ready ( ) . then ( ( ) => { isReady = true ; const hrTime = process . hrtime ( startTime ) ; const hrTimeMs = ( ( hrTime [ 0 ] * 1e9 ) + hrTime [ 1 ] ) / 1e6 ; console . log ( `λ Cold start took: ${ hrTimeMs }ms` ) ; } ) . catch ( ( error ) => { console . error ( 'λ Error while initializing nuxt:' , error ) ; process . exit ( 1 ) ; } ) ; const { Server } = require ( 'http' ) as typeof import ( 'http' ) ; const { Bridge } = require ( './vercel__bridge.js' ) as typeof import ( '@vercel/node-bridge/bridge' ) ; const requestListener = async ( req , res ) => { if ( ! isReady ) { await readyPromise ; } nuxt . server . app ( req , res ) ; } ; const server = new Server ( requestListener ) ; const bridge = new Bridge ( server ) ; bridge . listen ( ) ; if ( true ) { const internalServer = new Server ( requestListener ) ; internalServer . listen ( 3000 , '127.0.0.1' ) ; } export const launcher = bridge . launcher ;