Update auth-routes example

This commit is contained in:
Sebastien Chopin 2017-05-29 17:00:01 +02:00
parent ec9e334ed6
commit d481da9df0
4 changed files with 30 additions and 24 deletions

View File

@ -6,5 +6,8 @@ module.exports = {
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', content: 'Auth Routes example' }
]
},
build: {
vendor: ['axios']
}
}

View File

@ -2,16 +2,16 @@
"name": "auth-routes",
"description": "",
"dependencies": {
"axios": "^0.15.3",
"body-parser": "^1.15.2",
"cross-env": "^3.1.3",
"express": "^4.14.0",
"express-session": "^1.14.2",
"nuxt": "latest"
"axios": "^0.16.1",
"body-parser": "^1.17.2",
"cross-env": "^5.0.0",
"express": "^4.15.3",
"express-session": "^1.15.3",
"nuxt": "^1.0.0-alpha1"
},
"scripts": {
"dev": "node server.js",
"build": "nuxt build",
"start": "cross-env NODE_ENV=production & node server.js"
"start": "cross-env NODE_ENV=production node server.js"
}
}

View File

@ -1,7 +1,8 @@
const Nuxt = require('../../')
const Nuxt = require('nuxt')
const bodyParser = require('body-parser')
const session = require('express-session')
const app = require('express')()
const host = process.env.HOST || '127.0.0.1'
const port = process.env.PORT || '3000'
@ -36,9 +37,10 @@ let config = require('./nuxt.config.js')
config.dev = !(process.env.NODE_ENV === 'production')
// Init Nuxt.js
const nuxt = new Nuxt(config)
new Nuxt(config)
.then((nuxt) => {
// nuxt middlware
app.use(nuxt.render)
// Build only in dev mode
if (config.dev) {
nuxt.build()
@ -47,7 +49,8 @@ if (config.dev) {
process.exit(1)
})
}
// Listen the server
app.listen(port, host)
console.log('Server listening on ' + host + ':' + port) // eslint-disable-line no-console
})

View File

@ -1,8 +1,8 @@
import axios from 'axios'
export const state = {
export const state = () => ({
authUser: null
}
})
export const mutations = {
SET_USER: function (state, user) {