How to use the nuxt.Nuxt 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 / electron-template / template / main.js View on Github external
/*
**  Nuxt
*/
const http = require('http')
const { Nuxt, Builder } = require('nuxt')
let config = require('./nuxt.config.js')
config.rootDir = __dirname // for electron-builder
// Init Nuxt.js
const nuxt = new Nuxt(config)
const builder = new Builder(nuxt)
const server = http.createServer(nuxt.render)
// Build only in dev mode
if (config.dev) {
	builder.build().catch(err => {
		console.error(err) // eslint-disable-line no-console
		process.exit(1)
	})
}
// Listen the server
server.listen()
const _NUXT_URL_ = `http://localhost:${server.address().port}`
console.log(`Nuxt working on ${_NUXT_URL_}`)

/*
** Electron
github nuxt / nuxt.js / examples / with-feathers / src / middleware / nuxt.js View on Github external
import { resolve } from 'path'
import { Nuxt, Builder } from 'nuxt'

// Setup nuxt.js
let config = {}
try {
  config = require('../../nuxt.config.js')
} catch (e) {}
config.rootDir = resolve(__dirname, '..', '..')
config.dev = process.env.NODE_ENV !== 'production'

const nuxt = new Nuxt(config)
if (config.dev) {
  const builder = new Builder(nuxt)
  builder.build().then(() => process.emit('nuxt:build:done'))
} else {
  process.nextTick(() => process.emit('nuxt:build:done'))
}

// Add nuxt.js middleware
export default function (req, res) {
  nuxt.render(req, res)
}
github binbytes / nuxt-chat-app / server / index.js View on Github external
app.use(session({
  secret: process.env.secretKey || '7CigmgctzNfojD5D3eJ7tY62axBuFICn',
  resave: false,
  saveUninitialized: false,
  cookie: { maxAge: 60000 }
}))

// Import API Routes
app.use('/api', routes)

// Import and Set Nuxt.js options
let config = require('../nuxt.config.js')
config.dev = !(process.env.NODE_ENV === 'production')

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

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

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

// Listen the server
// app.listen(port, host)
server.listen(port, host)
console.log('Server listening on ' + host + ':' + port) // eslint-disable-line no-console
github Human-Connection / Human-Connection / webapp / server / index.js View on Github external
async function start() {
  // Init Nuxt.js
  const nuxt = new Nuxt(config)

  // 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,
  })
github jkchao / blog-front / server / index.js View on Github external
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 in development
  if (config.dev) {
    const builder = new Builder(nuxt)
    await builder.build()
  }

  app.use(ctx => {
    ctx.status = 200
    ctx.respond = false // Bypass Koa's built-in response handling
    ctx.req.ctx = ctx // This might be useful later on, e.g. in nuxtServerInit or with nuxt-stash
github richardeschloss / nuxt-socket-io / 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
  server.listen(port, host)
  consola.ready({
github AngelMunoz / sails-nuxt / config / nuxt.js View on Github external
/**
 * nuxt config and init
 */
const { Nuxt, Builder } = require('nuxt');

// Require Nuxt config
const config = require('../nuxt.config');

// Create a new Nuxt instance
const nuxt = new Nuxt(config);

// Enable live build & reloading on dev
if (nuxt.options.dev) {
  new Builder(nuxt).build();
}

module.exports = { nuxt };
github ezypeeze / nuxt-neo / tests / _bootstrap.js View on Github external
jasmine.DEFAULT_TIMEOUT_INTERVAL = 20000;
process.env.PORT                 = process.env.PORT || 3000;
process.env.HOST                 = process.env.HOST || 'localhost';
process.env.NODE_ENV             = 'testing';

global.TestController = require('./fixtures/test_controller');

const { Nuxt, Builder } = require('nuxt');
const axios = require('axios');
const URL = path => `http://${process.env.HOST}:${process.env.PORT}${path || ''}`;
const nuxt = new Nuxt(require('./fixtures/nuxt.config'));

async function globalBeforeAll () {
    await new Builder(nuxt).build();
    await nuxt.listen(process.env.PORT, 'localhost');
}

async function globalAfterAll () {
    await nuxt.close();
}

const api = axios.create({
    baseURL: URL('/api')
});

module.exports = {nuxt, Builder, URL, globalBeforeAll, globalAfterAll, api};
github potato4d / nuxt-firebase-sns-example / functions / index.js View on Github external
const app = express()

const envs = functions.config().environment

Object.entries(envs).forEach((k, v) => {
  process.env[`${k}`.toUpperCase()] = v
})

const config = {
  dev: false,
  buildDir: '.nuxt',
  build: {
    publicPath: '/assets/'
  }
}
const nuxt = new Nuxt(config)

function handleRequest(req, res) {
  res.set('Cache-Control', 'public, max-age=10, s-maxage=10')
  return new Promise((resolve, reject) => {
    nuxt.render(req, res, promise => {
      promise.then(resolve).catch(reject)
    })
  })
}

app.use(handleRequest)
exports.ssr = functions.https.onRequest(app)
github muhibbudins / nuxt-multiple / template / app / blog / index.js View on Github external
/**
 * Use given APIs
 */
app.use('/api', api)

/**
 * Import and use Nuxt.js configuration
 */
let config = require('./app.config.js')
config.dev = !(process.env.NODE_ENV === 'production')

/**
 * Create new instance of Nuxt
 */
const nuxt = new Nuxt(config)

/**
 * Set build only on development mode
 */
if (config.dev) {
  const builder = new Builder(nuxt)
  builder.build()
}

/**
 * Use Nuxt renderer on Express
 */
app.use(nuxt.render)

/**
 * Start App

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