diff --git a/app.js b/app.js index 483d087..644e223 100644 --- a/app.js +++ b/app.js @@ -1,4 +1,11 @@ var express = require('express'); +var path = require('path'); +var fs = require('fs'); +var logger = require('morgan'); +var compression = require('compression'); +var cookieParser = require('cookie-parser'); +var bodyParser = require('body-parser'); + var config = require('./config/admin'); var app = express(); @@ -7,31 +14,17 @@ var app = express(); var pub = __dirname + '/public'; var view = __dirname + '/views'; -app.configure(function() { - app.set('view engine', 'html'); - app.set('views', view); - app.engine('.html', require('ejs').__express); +app.use(compression()); - app.use(express.methodOverride()); - app.use(express.bodyParser()); - app.set('basepath', __dirname); -}); +app.use(logger(':method :url :response-time ms')); +app.use(bodyParser.urlencoded({ extended: true })); +app.use(bodyParser.json({ type: '*/*' })); +app.use(cookieParser()); +app.use(express.static(path.join(__dirname, 'public'))); -app.configure('development', function() { - app.use(express.static(pub)); - app.use(express.errorHandler({ - dumpExceptions: true, - showStack: true - })); -}); - -app.configure('production', function() { - var oneYear = 31557600000; - app.use(express.static(pub, { - maxAge: oneYear - })); - app.use(express.errorHandler()); -}); +app.set('view engine', 'html'); +app.set('views', view); +app.engine('.html', require('ejs').__express); app.on('error', function(err) { console.error('app on error:' + err.stack); diff --git a/package.json b/package.json index 9c77eec..b4c9c06 100755 --- a/package.json +++ b/package.json @@ -1,9 +1,13 @@ { - "name": "pomelo-admin-web", - "version": "0.2.0", - "private": false, - "dependencies": { - "express": "<4.0.0", - "ejs": ">=0.0.1" - } + "name": "pomelo-admin-web", + "version": "0.2.0", + "private": false, + "dependencies": { + "body-parser": "^1.16.1", + "compression": "^1.6.2", + "cookie-parser": "^1.4.3", + "ejs": "2.5.6", + "express": "4.14.1", + "morgan": "^1.8.1" + } }