Skip to content

Instantly share code, notes, and snippets.

@christopher4lis
Last active July 28, 2020 03:37
Show Gist options
  • Save christopher4lis/4dd8d052c93ad55f47e327bc6be1ae6a to your computer and use it in GitHub Desktop.
Save christopher4lis/4dd8d052c93ad55f47e327bc6be1ae6a to your computer and use it in GitHub Desktop.
Contents of /server directory scaffolded by older versions of create-nuxt-app
const express = require('express')
const consola = require('consola')
const { Nuxt, Builder } = require('nuxt')
const app = express()
// Import and Set Nuxt.js options
const config = require('../nuxt.config.js')
config.dev = process.env.NODE_ENV !== 'production'
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()
{
"name": "node-authentication",
"version": "1.0.0",
"description": "My prime Nuxt.js project",
"author": "ChrisCourses",
"private": true,
"scripts": {
"dev": "cross-env NODE_ENV=development nodemon server/index.js --watch server",
"build": "nuxt build",
"start": "cross-env NODE_ENV=production node server/index.js",
"generate": "nuxt generate",
"lint": "eslint --ext .js,.vue --ignore-path .gitignore .",
"test": "jest"
},
"lint-staged": {
"*.{js,vue}": "eslint"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"dependencies": {
"nuxt": "^2.0.0",
"cross-env": "^5.2.0",
"express": "^4.16.4",
"@nuxtjs/axios": "^5.3.6",
"@nuxtjs/pwa": "^3.0.0-0"
},
"devDependencies": {
"nodemon": "^1.18.9",
"@nuxtjs/tailwindcss": "^1.0.0",
"@nuxtjs/eslint-config": "^1.0.1",
"@nuxtjs/eslint-module": "^1.0.0",
"babel-eslint": "^10.0.1",
"eslint": "^6.1.0",
"eslint-plugin-nuxt": ">=0.4.2",
"eslint-config-prettier": "^4.1.0",
"eslint-plugin-prettier": "^3.0.1",
"prettier": "^1.16.4",
"husky": "^2.6.0",
"lint-staged": "^8.2.1",
"@vue/test-utils": "^1.0.0-beta.27",
"babel-jest": "^24.1.0",
"jest": "^24.1.0",
"vue-jest": "^4.0.0-0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment