Skip to content

Commit

Permalink
🐛 创建中间暴露到index,修复controller出错时候的信息
Browse files Browse the repository at this point in the history
  • Loading branch information
kongnet committed Sep 18, 2019
1 parent 48cc233 commit 8c00a07
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [0.1.56](https://github.com/kongnet/skybase/compare/v0.1.55...v0.1.56) (2019-09-09)




## [0.1.55](https://github.com/kongnet/skybase/compare/v0.1.54...v0.1.55) (2019-09-09)


Expand Down
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
const start = require('./lib/sky')
const createIoredis = require('./sky-module/create_ioredis')
const createRbmq = require('./sky-module/create_amqplib')
const createKafka = require('./sky-module/create_kafka.js')

module.exports = {
start
start,
createIoredis,
createRbmq,
createKafka
}
5 changes: 5 additions & 0 deletions lib/middleware/sky-api-register.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ const limitReqAction = (action, apiPath) => {
await action(ctx, next)
} catch (e) {
console.error('[controller error]', e)
ctx.body = {
code: 406,
data: {},
msg: `[controller error]`
}
}
} else {
ctx.body = {
Expand Down
2 changes: 1 addition & 1 deletion lib/middleware/sky-check-param.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const apiCheckLog = function (url, obj, method, oldParam, ctx) {
obj = obj || {}
if (obj.code >= 400) { checkColor = 'y' }
let methodStr = method.toUpperCase()
$.log($.c[{ 'GET': 'dimg', 'POST': 'dimy' }[methodStr]](`[ ${methodStr} ]`) + $.c.dimy(url.join ? url.join('/') : url) + $.c[checkColor](JSON.stringify(obj || '{}')), '实际参数:', oldParam ? $.c.r(JSON.stringify(oldParam || '{}')) : '', 'header参数:', $.c.r(JSON.stringify(ctx.header || '{}')))
$.log($.c[{ 'GET': 'dimg', 'POST': 'dimy' }[methodStr]](`[ ${methodStr} ]`) + $.c.dimy(url.join ? url.join('/') : url) + $.c[checkColor](JSON.stringify(obj || '{}')), '实际参数:', oldParam ? $.c.r(JSON.stringify(oldParam || '{}')) : '', 'header参数:', $.c.c(JSON.stringify(ctx.header || '{}')))
}
}

Expand Down

0 comments on commit 8c00a07

Please sign in to comment.