diff --git a/server/commons/Handler.coffee b/server/commons/Handler.coffee index 2f81d0acd..ada7acad3 100644 --- a/server/commons/Handler.coffee +++ b/server/commons/Handler.coffee @@ -261,7 +261,7 @@ module.exports = class Handler tv4 = require('tv4').tv4 res = tv4.validateMultiple(input, @jsonSchema) res - + @isID: (id) -> _.isString(id) and id.length is 24 and id.match(/[a-z0-9]/gi)?.length is 24 getDocumentForIdOrSlug: (idOrSlug, done) -> diff --git a/server_setup.coffee b/server_setup.coffee index ad23a6bf1..ff04b7b15 100644 --- a/server_setup.coffee +++ b/server_setup.coffee @@ -47,6 +47,8 @@ setupExpressMiddleware = (app) -> app.use(express.bodyParser()) app.use(express.methodOverride()) app.use(express.cookieSession({secret:'defenestrate'})) + if config.isProduction + app.use(express.compress()) setupPassportMiddleware = (app) -> app.use(authentication.initialize()) @@ -115,3 +117,5 @@ exports.setExpressConfigurationOptions = (app) -> app.set('views', __dirname + '/app/views') app.set('view engine', 'jade') app.set('view options', { layout: false }) + app.set('env', if config.isProduction then 'production' else 'development') + app.set('json spaces', 0)