|
|
@ -1,15 +1,15 @@
|
|
|
|
var express = require('express');
|
|
|
|
var express = require('express');
|
|
|
|
var path = require('path');
|
|
|
|
var path = require('path');
|
|
|
|
var favicon = require('serve-favicon');
|
|
|
|
//var favicon = require('serve-favicon');
|
|
|
|
var logger = require('morgan');
|
|
|
|
var logger = require('morgan');
|
|
|
|
var cookieParser = require('cookie-parser');
|
|
|
|
var cookieParser = require('cookie-parser');
|
|
|
|
var bodyParser = require('body-parser');
|
|
|
|
var bodyParser = require('body-parser');
|
|
|
|
var session = require('express-session');
|
|
|
|
var session = require('express-session');
|
|
|
|
var MemoryStore = require('memorystore')(session)
|
|
|
|
var MemoryStore = require('memorystore')(session);
|
|
|
|
var flash = require('connect-flash');
|
|
|
|
var flash = require('connect-flash');
|
|
|
|
var theme = "default-dark";
|
|
|
|
var theme = 'default-dark';
|
|
|
|
var app = express();
|
|
|
|
var app = express();
|
|
|
|
var request = require('request');
|
|
|
|
//var request = require('request');
|
|
|
|
// view engine setup
|
|
|
|
// view engine setup
|
|
|
|
app.set('views', path.join(__dirname, '../themes'));
|
|
|
|
app.set('views', path.join(__dirname, '../themes'));
|
|
|
|
app.set('view engine', 'pug');
|
|
|
|
app.set('view engine', 'pug');
|
|
|
@ -17,28 +17,28 @@ app.use(express.static(__dirname + '../content/folio-images'));
|
|
|
|
app.use(logger('dev'));
|
|
|
|
app.use(logger('dev'));
|
|
|
|
|
|
|
|
|
|
|
|
app.use(bodyParser.json({ limit: '50mb' }));
|
|
|
|
app.use(bodyParser.json({ limit: '50mb' }));
|
|
|
|
app.use(bodyParser.urlencoded(
|
|
|
|
app.use(
|
|
|
|
{
|
|
|
|
bodyParser.urlencoded({
|
|
|
|
extended: false,
|
|
|
|
extended: false,
|
|
|
|
limit: '50mb'
|
|
|
|
limit: '50mb'
|
|
|
|
}));
|
|
|
|
})
|
|
|
|
|
|
|
|
);
|
|
|
|
app.use(cookieParser());
|
|
|
|
app.use(cookieParser());
|
|
|
|
app.use(express.static(path.join(__dirname, '../content')));
|
|
|
|
app.use(express.static(path.join(__dirname, '../content')));
|
|
|
|
app.use(express.static(path.join(__dirname, '../themes')));
|
|
|
|
app.use(express.static(path.join(__dirname, '../themes')));
|
|
|
|
app.use(session(
|
|
|
|
app.use(
|
|
|
|
{
|
|
|
|
session({
|
|
|
|
store: new MemoryStore(
|
|
|
|
store: new MemoryStore({
|
|
|
|
{
|
|
|
|
|
|
|
|
checkPeriod: 86400000 // prune expired entries every 24h
|
|
|
|
checkPeriod: 86400000 // prune expired entries every 24h
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
secret: '1KqZ18W8KskE1iSw',
|
|
|
|
secret: '1KqZ18W8KskE1iSw',
|
|
|
|
saveUninitialized: false,
|
|
|
|
saveUninitialized: false,
|
|
|
|
resave: false,
|
|
|
|
resave: false,
|
|
|
|
cookie:
|
|
|
|
cookie: {
|
|
|
|
{
|
|
|
|
|
|
|
|
maxAge: 608800000
|
|
|
|
maxAge: 608800000
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
})
|
|
|
|
|
|
|
|
);
|
|
|
|
app.use(flash());
|
|
|
|
app.use(flash());
|
|
|
|
//sections
|
|
|
|
//sections
|
|
|
|
var front = require('./routes/front/index')(session);
|
|
|
|
var front = require('./routes/front/index')(session);
|
|
|
@ -63,8 +63,7 @@ app.use('/@/dashboard/settings', settingsDashboard);
|
|
|
|
app.use('/@/dashboard/navigation', navDashboard);
|
|
|
|
app.use('/@/dashboard/navigation', navDashboard);
|
|
|
|
//app.use('/mailer', mailer);
|
|
|
|
//app.use('/mailer', mailer);
|
|
|
|
// catch 404 and forward to error handler
|
|
|
|
// catch 404 and forward to error handler
|
|
|
|
app.use(function(req, res, next)
|
|
|
|
app.use(function(req, res, next) {
|
|
|
|
{
|
|
|
|
|
|
|
|
var err = new Error('Not Found');
|
|
|
|
var err = new Error('Not Found');
|
|
|
|
err.status = 404;
|
|
|
|
err.status = 404;
|
|
|
|
next(err);
|
|
|
|
next(err);
|
|
|
@ -72,13 +71,10 @@ app.use(function(req, res, next)
|
|
|
|
// error handlers
|
|
|
|
// error handlers
|
|
|
|
// development error handler
|
|
|
|
// development error handler
|
|
|
|
// will print stacktrace
|
|
|
|
// will print stacktrace
|
|
|
|
if (app.get('env') === 'development')
|
|
|
|
if (app.get('env') === 'development') {
|
|
|
|
{
|
|
|
|
app.use(function(err, req, res) {
|
|
|
|
app.use(function(err, req, res, next)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
res.status(err.status || 500);
|
|
|
|
res.status(err.status || 500);
|
|
|
|
res.render(theme + '/error',
|
|
|
|
res.render(theme + '/error', {
|
|
|
|
{
|
|
|
|
|
|
|
|
message: err.message,
|
|
|
|
message: err.message,
|
|
|
|
error: err
|
|
|
|
error: err
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -86,14 +82,11 @@ if (app.get('env') === 'development')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// production error handler
|
|
|
|
// production error handler
|
|
|
|
// no stacktraces leaked to user
|
|
|
|
// no stacktraces leaked to user
|
|
|
|
app.use(function(err, req, res, next)
|
|
|
|
app.use(function(err, req, res) {
|
|
|
|
{
|
|
|
|
|
|
|
|
res.status(err.status || 500);
|
|
|
|
res.status(err.status || 500);
|
|
|
|
res.render(theme + '/error',
|
|
|
|
res.render(theme + '/error', {
|
|
|
|
{
|
|
|
|
|
|
|
|
message: err.message,
|
|
|
|
message: err.message,
|
|
|
|
error:
|
|
|
|
error: {}
|
|
|
|
{}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
module.exports = app;
|
|
|
|
module.exports = app;
|