提交 c288faeec16a8a64014d99b46980e8de74b4d6ad

作者 Nick Baugh
1 个父辈 b9fe49ef

Fixed error handler status code, Removed nifty-mongoose-types

@@ -3,7 +3,6 @@ @@ -3,7 +3,6 @@
3 3
4 var mongoose = require('mongoose') 4 var mongoose = require('mongoose')
5 var _ = require('underscore') 5 var _ = require('underscore')
6 -var mongooseTypes = require('nifty-mongoose-types')  
7 6
8 exports = module.exports = function(logger, settings) { 7 exports = module.exports = function(logger, settings) {
9 8
@@ -20,11 +19,6 @@ exports = module.exports = function(logger, settings) { @@ -20,11 +19,6 @@ exports = module.exports = function(logger, settings) {
20 logger.info('mongo connection opened') 19 logger.info('mongo connection opened')
21 }) 20 })
22 21
23 - connection.Schema = mongoose.Schema  
24 - connection.SchemaTypes = mongoose.SchemaTypes  
25 - connection.Types = mongoose.SchemaTypes  
26 - mongooseTypes.loadTypes(connection)  
27 -  
28 return connection 22 return connection
29 23
30 } 24 }
@@ -33,10 +33,14 @@ exports = module.exports = function(logger, settings) { @@ -33,10 +33,14 @@ exports = module.exports = function(logger, settings) {
33 var error = {} 33 var error = {}
34 34
35 // set error type 35 // set error type
  36 + error.type = res.statusCode < 500 ? 'invalid_request_error' : 'api_error'
  37 +
  38 + /*
36 error.type = _.isString(err.param) ? 'invalid_request_error' : 'api_error' 39 error.type = _.isString(err.param) ? 'invalid_request_error' : 'api_error'
37 40
38 if (error.type === 'invalid_request_error' && res.statusCode === 500) 41 if (error.type === 'invalid_request_error' && res.statusCode === 500)
39 res.statusCode = 400 42 res.statusCode = 400
  43 + */
40 44
41 // set error message and stack trace 45 // set error message and stack trace
42 if (util.isError(err)) { 46 if (util.isError(err)) {
@@ -21,7 +21,6 @@ @@ -21,7 +21,6 @@
21 "express-session": "^1.2.1", 21 "express-session": "^1.2.1",
22 "merge-defaults": "^0.1.0", 22 "merge-defaults": "^0.1.0",
23 "mongoose": "~3.8.7", 23 "mongoose": "~3.8.7",
24 - "nifty-mongoose-types": "0.0.2",  
25 "to-camel-case": "^0.2.1", 24 "to-camel-case": "^0.2.1",
26 "underscore": "~1.6.0", 25 "underscore": "~1.6.0",
27 "update-notifier": "git://github.com/niftylettuce/update-notifier", 26 "update-notifier": "git://github.com/niftylettuce/update-notifier",
注册登录 后发表评论