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' }, { name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', content: 'Auth Routes example' } { hid: 'description', content: 'Auth Routes example' }
] ]
},
build: {
vendor: ['axios']
} }
} }

View File

@ -2,16 +2,16 @@
"name": "auth-routes", "name": "auth-routes",
"description": "", "description": "",
"dependencies": { "dependencies": {
"axios": "^0.15.3", "axios": "^0.16.1",
"body-parser": "^1.15.2", "body-parser": "^1.17.2",
"cross-env": "^3.1.3", "cross-env": "^5.0.0",
"express": "^4.14.0", "express": "^4.15.3",
"express-session": "^1.14.2", "express-session": "^1.15.3",
"nuxt": "latest" "nuxt": "^1.0.0-alpha1"
}, },
"scripts": { "scripts": {
"dev": "node server.js", "dev": "node server.js",
"build": "nuxt build", "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 bodyParser = require('body-parser')
const session = require('express-session') const session = require('express-session')
const app = require('express')() const app = require('express')()
const host = process.env.HOST || '127.0.0.1' const host = process.env.HOST || '127.0.0.1'
const port = process.env.PORT || '3000' const port = process.env.PORT || '3000'
@ -36,9 +37,10 @@ let config = require('./nuxt.config.js')
config.dev = !(process.env.NODE_ENV === 'production') config.dev = !(process.env.NODE_ENV === 'production')
// Init Nuxt.js // Init Nuxt.js
const nuxt = new Nuxt(config) new Nuxt(config)
.then((nuxt) => {
// nuxt middlware
app.use(nuxt.render) app.use(nuxt.render)
// Build only in dev mode // Build only in dev mode
if (config.dev) { if (config.dev) {
nuxt.build() nuxt.build()
@ -47,7 +49,8 @@ if (config.dev) {
process.exit(1) process.exit(1)
}) })
} }
// Listen the server // Listen the server
app.listen(port, host) app.listen(port, host)
console.log('Server listening on ' + host + ':' + port) // eslint-disable-line no-console console.log('Server listening on ' + host + ':' + port) // eslint-disable-line no-console
})

View File

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