mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 23:52:06 +00:00
Update auth-routes example
This commit is contained in:
parent
ec9e334ed6
commit
d481da9df0
@ -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']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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,18 +37,20 @@ 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)
|
||||||
app.use(nuxt.render)
|
.then((nuxt) => {
|
||||||
|
// nuxt middlware
|
||||||
|
app.use(nuxt.render)
|
||||||
|
// Build only in dev mode
|
||||||
|
if (config.dev) {
|
||||||
|
nuxt.build()
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error) // eslint-disable-line no-console
|
||||||
|
process.exit(1)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// Listen the server
|
||||||
|
app.listen(port, host)
|
||||||
|
console.log('Server listening on ' + host + ':' + port) // eslint-disable-line no-console
|
||||||
|
})
|
||||||
|
|
||||||
// Build only in dev mode
|
|
||||||
if (config.dev) {
|
|
||||||
nuxt.build()
|
|
||||||
.catch((error) => {
|
|
||||||
console.error(error) // eslint-disable-line no-console
|
|
||||||
process.exit(1)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Listen the server
|
|
||||||
app.listen(port, host)
|
|
||||||
console.log('Server listening on ' + host + ':' + port) // eslint-disable-line no-console
|
|
||||||
|
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user