How to use the nuxt.Builder function in nuxt

To help you get started, we’ve selected a few nuxt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nuxt-community / nuxtent-module / test / e2e / common / nuxt.js View on Github external
const commonBefore = (nuxtentConfig, config = {}) => async () => {
  const mergedConfig = {
    ...baseConfig(nuxtentConfig),
    ...config
  }

  // Build a fresh nuxt
  nuxt = new Nuxt(mergedConfig)
  await new Builder(nuxt).build()
  await nuxt.listen(process.env.PORT)
}
github surmon-china / surmon.me / server / index.js View on Github external
app.use(nuxt.render)
app.set('port', port)

const bootstrap = () => {
  server.listen(port, host)
  const appName = config.manifest.name
  const envText = isDevMode ? '开发模式' : '生产模式'
  console.info(`${appName} ${envText}启动成功!listening on ${host}:${port}, at ${new Date().toLocaleString()}`)
  // 启动扩展服务
  updateGAScript()
  barrageServer(io)
  webrtcServer(io)
}

if (config.dev) {
  new Builder(nuxt)
    .build()
    .then(bootstrap)
    .catch((error) => {
      console.error('开发模式启动失败:', error)
      process.exit(1)
    })
} else {
  bootstrap()
}
github warriorBrian / nuxt-blog / mobile / server / index.js View on Github external
async function start() {
  // Instantiate nuxt.js
  const nuxt = new Nuxt(config)

  // Build in development
  if (config.dev) {
    const builder = new Builder(nuxt)
    await builder.build()
  }

  app.use(ctx => {
    ctx.status = 200 // koa defaults to 404 when it sees that status is unset

    return new Promise((resolve, reject) => {
      ctx.res.on('close', resolve)
      ctx.res.on('finish', resolve)
      nuxt.render(ctx.req, ctx.res, promise => {
        // nuxt.render passes a rejected promise into callback on error.
        promise.then(resolve).catch(reject)
      })
    })
  })
github breach-tw / breach.tw / server / index.js View on Github external
async function start() {
  // Instantiate nuxt.js
  const nuxt = new Nuxt(nuxtConfig)

  const {
    host = process.env.HOST || '127.0.0.1',
    port = process.env.PORT || 3000
  } = nuxt.options.server

  // Build in development
  if (nuxtConfig.dev) {
    const builder = new Builder(nuxt)
    await builder.build()
  } else {
    await nuxt.ready()
  }

  app.use(koaBody({
    formidable:{
      uploadDir: config.uploadDir,
      maxFileSize: 10*1024*1024*1024 // 10G
    },
    multipart: true,
    parsedMethods: ['POST', 'DELETE', 'PATCH']
  }));

  router.use('/api', api.routes(), api.allowedMethods())
  app.use(router.routes()).use(router.allowedMethods())
github Uconnect-Technologies / wertik-js / frontend-app / vue-app / server / index.js View on Github external
async function start() {
  // Init 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()
  }

  // Give nuxt middleware to express
  app.use(nuxt.render)

  // Listen the server
  app.listen(port, host)
  consola.ready({
    message: `Server listening on http://${host}:${port}`,
    badge: true
  })
}
start()
github google / wikiloop-battlefield / server / index.js View on Github external
app.use(universalAnalytics.middleware(process.env.GA_ID, {cookieName: '_ga'}));
  app.use(bodyParser());
  app.use(logReqPerf);

  const server = http.Server(app);
  const io = require('socket.io')(server);
  app.set('socketio', io);

  // Init Nuxt.js
  const nuxt = new Nuxt(config)

  const {host, port} = nuxt.options.server

  // Build only in dev mode
  if (config.dev) {
    const builder = new Builder(nuxt)
    await builder.build()
  } else {
    await nuxt.ready()
  }

  await mongoose.connect(process.env.MONGODB_URI, { useNewUrlParser: true, dbName: process.env.MONGODB_DB} );

  app.use(function (req, res, next) {
    apiLogger.debug('req.originalUrl:', req.originalUrl);
    apiLogger.debug('req.params:', req.params);
    apiLogger.debug('req.query:', req.query);
    next();
  });
  if (useOauth) setupAuthApi(mongoose.connection.db, app);
  setupIoSocketListener(mongoose.connection.db, io);
  setupMediaWikiListener(mongoose.connection.db, io);
github repl-it-discord / carnival / front / server / index.js View on Github external
async function start() {
  // Init Nuxt.js
  const nuxt = new Nuxt(config);

  const { host, port } = nuxt.options.server;

  // Build only in dev mode
  if (config.dev) {
    const builder = new Builder(nuxt);
    await builder.build();
  } else {
    await nuxt.ready();
  }

  // Give nuxt middleware to express
  app.use(nuxt.render);

  // Listen the server
  app.listen(port, host);
  consola.ready({
    message: `Server listening on http://${host}:${port}`,
    badge: true
  });
}
start();
github chanlito / nuxt-ts-starter / server / index.ts View on Github external
(async function main() {
  const app = express();
  const nuxt = new Nuxt({ ...require(resolve('.', 'nuxt.config.js')), dev });

  app.use(compression());
  app.use('/api', catRoutes);

  if (dev) await new Builder(nuxt).build();
  app.use(nuxt.render);

  app.listen(PORT, () => console.log(`> Listening on port ${PORT}`));
})();
github mya-ake / nuxt-on-lambda / server / local.js View on Github external
const start = async () => {
  if (config.dev) {
    const builder = new Builder(nuxt)
    await builder.build()
  }

  app.listen(port, host)
  consola.ready({
    message: `Server listening on http://${host}:${port}`,
    badge: true
  })
}
github tonyfromundefined / nuxt-serverless / server.js View on Github external
(async function main() {
  if (!IS_PROD) {
    await new Builder(nuxt).build()
  }

  app.listen(PORT)
})()

nuxt

Nuxt is a free and open-source framework with an intuitive and extendable way to create type-safe, performant and production-grade full-stack web applications and websites with Vue.js.

MIT
Latest version published 2 days ago

Package Health Score

83 / 100
Full package analysis