text: const { Nuxt, Builder } = require('nuxt<% if (edge) { %>-edge<% } %>')
  const fastify = require('fastify')({
    logger: true
  })
  
  // Import and Set Nuxt.js options
  const config = require('../nuxt.config.js')
  config.dev = !(process.env.NODE_ENV === 'production')
  
  async function start() {
    // Instantiate nuxt.js
    const nuxt = new Nuxt(config)
  
    const {
      host = process.env.HOST || '127.0.0.1',
      port = process.env.PORT || 3000
    } = nuxt.options.server
  
    // Build only in dev mode
    if (config.dev) {
      const builder = new Builder(nuxt)
      await builder.build()
    } else {
      await nuxt.ready()
    }
  
    fastify.use(nuxt.render)
  
    fastify.listen(port, host, (err, address) => {
      if (err) {
        fastify.log.error(err)
        process.exit(1)
      }
    })
  }
  
  start()
  