Skip to content

Instantly share code, notes, and snippets.

@leo91000
Last active November 24, 2018 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leo91000/856cef535019381a87f26375482a26a8 to your computer and use it in GitHub Desktop.
Save leo91000/856cef535019381a87f26375482a26a8 to your computer and use it in GitHub Desktop.
Project stylus isn't working
const express = require('express')
const consola = require('consola')
const apiConfig = require('./config')
const mongoose = require('mongoose')
const bodyParser = require('body-parser')
const passport = require('passport')
const LocalStrategy = require('passport-local').Strategy
const { Nuxt, Builder } = require('nuxt')
// Controller
const apiRouter = require('./routes')
const app = express()
const host = process.env.HOST || '127.0.0.1'
const port = process.env.PORT || 3000
mongoose.connect(
apiConfig.mongoUrl,
{ useNewUrlParser: true }
)
let db = mongoose.connection
db.on('error', console.error.bind(console, 'connection error:'))
db.once('open', function() {
app.set('port', port)
// Import and Set Nuxt.js options
let config = require('../nuxt.config.js')
config.dev = !(process.env.NODE_ENV === 'production')
async function start() {
// Init Body Parser
app.use(
bodyParser.json({
limit: apiConfig.bodyLimit
})
)
// Init password crypting
app.use(passport.initialize())
let User = require('./model/user')
passport.use(
new LocalStrategy(
{
usernameField: 'username',
passwordField: 'password'
},
User.authenticate()
)
)
passport.serializeUser(User.serializeUser())
passport.deserializeUser(User.deserializeUser())
// Controller routing
app.use('/api', apiRouter)
// 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
})
}
start()
})
const pkg = require('./package')
module.exports = {
mode: 'universal',
/*
** Headers of the page
*/
head: {
title: pkg.name,
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: pkg.description }
],
link: [
{
rel: 'icon',
type: 'image/x-icon',
href: '/favicon.ico'
},
{
rel: 'stylesheet',
href:
'https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons'
}
]
},
/*
** Customize the progress-bar color
*/
loading: { color: '#3B8070' },
/*
** Global CSS
*/
css: [{ src: '~/assets/style/app.styl', lang: 'styl'}],
/*
** Plugins to load before mounting the App
*/
plugins: ['~/plugins/vuetify.js'],
/*
** Nuxt.js modules
*/
modules: [
// Doc: https://github.com/nuxt-community/axios-module#usage
'@nuxtjs/axios'
],
/*
** Axios module configuration
*/
axios: {
// See https://github.com/nuxt-community/axios-module#options
},
/*
** Build configuration
*/
build: {
extractCSS: true,
/*
** You can extend webpack config here
*/
extend(config, ctx) {
// Run ESLint on save
if (ctx.isDev && process.client) {
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /(node_modules)/
})
}
}
}
}
{
"name": "lcoletta_blog",
"version": "1.0.0",
"description": "Blog de Léo Coletta",
"author": "Léo Coletta",
"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 .",
"lintfix": "eslint --fix --ext .js,.vue --ignore-path .gitignore .",
"precommit": "npm run lint"
},
"dependencies": {
"@nuxtjs/axios": "^5.3.6",
"app-root-path": "^2.1.0",
"body-parser": "^1.18.3",
"cross-env": "^5.2.0",
"express": "^4.16.3",
"express-jwt": "^5.3.1",
"express-rate-limit": "^3.3.2",
"express-winston": "^3.0.1",
"generate-password": "^1.4.1",
"google-auth-library": "^2.0.1",
"jsonwebtoken": "^8.4.0",
"lodash": "^4.17.11",
"mongoose": "^5.3.12",
"mongoose-ref-validator": "^1.0.21",
"mongoose-unique-validator": "^2.0.2",
"mongoose-validator": "^2.1.0",
"nodemailer": "^4.6.8",
"nuxt": "^2.3.1",
"passport": "^0.4.0",
"passport-local": "^1.0.0",
"passport-local-mongoose": "^5.0.1",
"vuetify": "^1.3.9",
"webpack-node-externals": "^1.7.2",
"winston": "^3.1.0"
},
"devDependencies": {
"babel-eslint": "^10.0.1",
"eslint": "^4.0.0",
"eslint-config-prettier": "^3.3.0",
"eslint-loader": "^2.1.1",
"eslint-plugin-prettier": "^3.0.0",
"eslint-plugin-vue": "^4.7.1",
"nodemon": "^1.18.6",
"prettier": "^1.14.3",
"stylus": "^0.54.5",
"stylus-loader": "^3.0.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment