Permalink
Browse files

getting this shit ready for production environment

  • Loading branch information...
Spraynard committed Oct 11, 2017
1 parent a0ccb35 commit 4a932734d39ebdaf03eaf8998cca8036e563287e
View
31 app.js
@@ -1,4 +1,5 @@
var express = require('express');
var minifyHTML = require('express-minify-html');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
@@ -12,8 +13,6 @@ var cookieDivide = require('./cookieDivider');
var mySQL = require('./my_sql_setup.js');
//Routing for index page
var index = require('./routes/index');
//Routing for users page
var users = require('./routes/users');
//Routing for projects page
var projects = require('./routes/projects');
//Routing for Contact Page
@@ -24,8 +23,7 @@ var login = require('./routes/login');
var logout = require('./routes/logout');
//Routing for Blog Page
var blog = require('./routes/blog');
//Routing for test-routes
// var test_routes = require('./routes/test/test-routes');
var app = express();
// APP LOCALS
@@ -42,6 +40,20 @@ app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');
app.use(helmet());
app.use(minifyHTML({
override: true,
exception_url: false,
htmlMinifier: {
removeComments: true,
collapseWhitespace: true,
collapseBooleanAttributes: true,
removeAttributeQuotes: true,
removeEmptyAttributes: true,
minifyJS: true
}
}));
// upload folder setup?
app.use('/uploads', express.static(path.join(__dirname, 'uploads')));
// uncomment after placing your favicon in /public
@@ -51,10 +63,11 @@ app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(sassMiddleware({
src: path.join(__dirname, 'public'),
src: path.join(__dirname, 'private'),
dest: path.join(__dirname, 'public'),
indentedSyntax: true, // true = .sass and false = .scss
sourceMap: true
sourceMap: true,
outputStyle: 'compressed'
}));
app.use(express.static(path.join(__dirname, 'public')));
@@ -75,9 +88,7 @@ app.use((req, res, next) => {
})
})
// app.all('*', test_routes);
app.use('/', index);
app.use('/users', users);
app.use('/projects', projects);
app.use('/contact', contact);
app.use('/blog', blog);
@@ -108,8 +119,4 @@ app.use(function(err, req, res, next) {
res.render('error');
});
// app.listen(8000).on('error', function(err) {
// console.error(err)
// })
module.exports = app;
View
@@ -3,14 +3,17 @@
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
"start": "node ./bin/www",
"start-prod" : "NODE_ENV=production PORT=8080 DEBUG=portfolio:* npm start",
"start-prod-no-debug" : "NODE_ENV=production PORT=8000 npm start"
},
"dependencies": {
"body-parser": "~1.17.1",
"compression": "^1.7.1",
"cookie-parser": "~1.4.3",
"debug": "^2.6.9",
"express": "^4.15.5",
"express-minify-html": "^0.11.4",
"helmet": "^3.8.2",
"moment": "~2.18.1",
"morgan": "~1.8.1",
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 4a93273

Please sign in to comment.