提交 c288faeec16a8a64014d99b46980e8de74b4d6ad
1 个父辈
b9fe49ef
Fixed error handler status code, Removed nifty-mongoose-types
正在显示
3 个修改的文件
包含
4 行增加
和
7 行删除
... | ... | @@ -3,7 +3,6 @@ |
3 | 3 | |
4 | 4 | var mongoose = require('mongoose') |
5 | 5 | var _ = require('underscore') |
6 | -var mongooseTypes = require('nifty-mongoose-types') | |
7 | 6 | |
8 | 7 | exports = module.exports = function(logger, settings) { |
9 | 8 | |
... | ... | @@ -20,11 +19,6 @@ exports = module.exports = function(logger, settings) { |
20 | 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 | 22 | return connection |
29 | 23 | |
30 | 24 | } | ... | ... |
... | ... | @@ -33,10 +33,14 @@ exports = module.exports = function(logger, settings) { |
33 | 33 | var error = {} |
34 | 34 | |
35 | 35 | // set error type |
36 | + error.type = res.statusCode < 500 ? 'invalid_request_error' : 'api_error' | |
37 | + | |
38 | + /* | |
36 | 39 | error.type = _.isString(err.param) ? 'invalid_request_error' : 'api_error' |
37 | 40 | |
38 | 41 | if (error.type === 'invalid_request_error' && res.statusCode === 500) |
39 | 42 | res.statusCode = 400 |
43 | + */ | |
40 | 44 | |
41 | 45 | // set error message and stack trace |
42 | 46 | if (util.isError(err)) { | ... | ... |
... | ... | @@ -21,7 +21,6 @@ |
21 | 21 | "express-session": "^1.2.1", |
22 | 22 | "merge-defaults": "^0.1.0", |
23 | 23 | "mongoose": "~3.8.7", |
24 | - "nifty-mongoose-types": "0.0.2", | |
25 | 24 | "to-camel-case": "^0.2.1", |
26 | 25 | "underscore": "~1.6.0", |
27 | 26 | "update-notifier": "git://github.com/niftylettuce/update-notifier", | ... | ... |
请
注册
或
登录
后发表评论