levinhax / egg-api Goto Github PK
View Code? Open in Web Editor NEWEgg.js、 MongoDB、 mongoose、 API
Egg.js、 MongoDB、 mongoose、 API
egg deprecated [egg-security] app.config.security.csrf.ignoreJSON
is not safe now, please disable it. node_modules_egg-core@4.11.0@egg-core\lib\lifecycle.js:93:9
2018-11-16 22:27:21,493 ERROR 6904 [egg-mongoose] mongodb://127.0.0.1/apiExample disconnected
2018-11-16 22:27:21,497 ERROR 6904 nodejs.MongoNetworkError: [egg-mongoose]failed to connect to server [127.0.0.1:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]
at Pool. (C:\Users\root\Downloads\Egg-API-master\Egg-API-master\node_modules_mongodb-core@3.1.7@mongodb-core\lib\topologies\server.js:564:11)
at Pool.emit (events.js:182:13)
at Connection. (C:\Users\root\Downloads\Egg-API-master\Egg-API-master\node_modules_mongodb-core@3.1.7@mongodb-core\lib\connection\pool.js:317:12)
at Object.onceWrapper (events.js:273:13)
at Connection.emit (events.js:182:13)
at Socket. (C:\Users\root\Downloads\Egg-API-master\Egg-API-master\node_modules_mongodb-core@3.1.7@mongodb-core\lib\connection\connection.js:246:50)
at Object.onceWrapper (events.js:273:13)
at Socket.emit (events.js:182:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
name: "MongoNetworkError"
errorLabels: ["TransientTransactionError"]
pid: 6904
hostname: DESKTOP-106KQGJ
2018-11-16 22:27:21,503 ERROR 6904 [-/127.0.0.1/-/1ms GET /] nodejs.MongoNetworkError: [egg-mongoose]failed to connect to server [127.0.0.1:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]
at Pool. (C:\Users\root\Downloads\Egg-API-master\Egg-API-master\node_modules_mongodb-core@3.1.7@mongodb-core\lib\topologies\server.js:564:11)
at Pool.emit (events.js:182:13)
at Connection. (C:\Users\root\Downloads\Egg-API-master\Egg-API-master\node_modules_mongodb-core@3.1.7@mongodb-core\lib\connection\pool.js:317:12)
at Object.onceWrapper (events.js:273:13)
at Connection.emit (events.js:182:13)
at Socket. (C:\Users\root\Downloads\Egg-API-master\Egg-API-master\node_modules_mongodb-core@3.1.7@mongodb-core\lib\connection\connection.js:246:50)
at Object.onceWrapper (events.js:273:13)
at Socket.emit (events.js:182:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
name: "MongoNetworkError"
errorLabels: ["TransientTransactionError"]
pid: 6904
hostname: DESKTOP-106KQGJ
2018-11-16 22:27:21,508 ERROR 6904 nodejs.MongoNetworkError: [egg-mongoose]failed to connect to server [127.0.0.1:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]
at Pool. (C:\Users\root\Downloads\Egg-API-master\Egg-API-master\node_modules_mongodb-core@3.1.7@mongodb-core\lib\topologies\server.js:564:11)
at Pool.emit (events.js:182:13)
at Connection. (C:\Users\root\Downloads\Egg-API-master\Egg-API-master\node_modules_mongodb-core@3.1.7@mongodb-core\lib\connection\pool.js:317:12)
at Object.onceWrapper (events.js:273:13)
at Connection.emit (events.js:182:13)
at Socket. (C:\Users\root\Downloads\Egg-API-master\Egg-API-master\node_modules_mongodb-core@3.1.7@mongodb-core\lib\connection\connection.js:246:50)
at Object.onceWrapper (events.js:273:13)
at Socket.emit (events.js:182:13)
at emitErrorNT (internal/streams/destroy.js:82:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
name: "MongoNetworkError"
errorLabels: ["TransientTransactionError"]
pid: 6904
hostname: DESKTOP-106KQGJ
2018-11-16 22:27:21,511 ERROR 6904 [app_worker] start error, exiting with code:1
[2018-11-16 22:27:21.524] [cfork:master:4972] worker:6904 disconnect (exitedAfterDisconnect: false, state: disconnected, isDead: false, worker.disableRefork: true)
2018-11-16 22:27:21,528 WARN 7056 [ClusterClient:Connection] socket is closed by other side while there were still unhandled data in the socket buffer
[2018-11-16 22:27:21.530] [cfork:master:4972] don't fork, because worker:6904 will be kill soon
2018-11-16 22:27:21,533 INFO 4972 [master] app_worker#1:6904 disconnect, suicide: false, state: disconnected, current workers: ["1"]
[2018-11-16 22:27:21.538] [cfork:master:4972] worker:6904 exit (code: 1, exitedAfterDisconnect: false, state: dead, isDead: true, isExpected: false, worker.disableRefork: true)
2018-11-16 22:27:21,541 ERROR 4972 nodejs.AppWorkerDiedError: [master] app_worker#1:6904 died (code: 1, signal: null, suicide: false, state: dead), current workers: []
at Master.onAppExit (C:\Users\root\Downloads\Egg-API-master\Egg-API-master\node_modules_egg-cluster@1.22.1@egg-cluster\lib\master.js:398:21)
at Master.emit (events.js:182:13)
at Messenger.sendToMaster (C:\Users\root\Downloads\Egg-API-master\Egg-API-master\node_modules_egg-cluster@1.22.1@egg-cluster\lib\utils\messenger.js:133:17)
at Messenger.send (C:\Users\root\Downloads\Egg-API-master\Egg-API-master\node_modules_egg-cluster@1.22.1@egg-cluster\lib\utils\messenger.js:98:12)
at EventEmitter.cluster.on (C:\Users\root\Downloads\Egg-API-master\Egg-API-master\node_modules_egg-cluster@1.22.1@egg-cluster\lib\master.js:267:22)
at EventEmitter.emit (events.js:187:15)
at ChildProcess.worker.process.once (internal/cluster/master.js:193:13)
at Object.onceWrapper (events.js:273:13)
at ChildProcess.emit (events.js:182:13)
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
name: "AppWorkerDiedError"
pid: 4972
hostname: DESKTOP-106KQGJ
2018-11-16 22:27:21,543 ERROR 4972 [master] app_worker#1:6904 start fail, exiting with code:1
2018-11-16 22:27:21,545 ERROR 4972 [master] exit with code:1
DEBUG=common-bin
for detail
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: egg-bin dev
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\root\AppData\Roaming\npm-cache_logs\2018-11-16T14_27_21_597Z-debug.log
Hello, where is the SQL file?
Thank you for a copy.
测试方法:api/v1/deleteuser
参数{"_id":"5c0e0db0f920d60a6d8dae04","userRole":"1","deleteUserId":"u1"}
返回状态码:404
Response Body:{"message":"Not Found"}
------分割线--------
请求数据中,用户角色是1。不满足 controller.user.deleteUser中userRole必须是3的rule.
ctx.validate失败,抛出422错误。
但是外面的errorHandler没有捕获到这个错误。
userMsg: {"_id":"5c0e0db0f920d60a6d8dae04","userRole":"1","deleteUserId":"u1"} { UnprocessableEntityError: Validation Failed at Object.throw (/Users/leo/VSCodeProjects/极刊登/ji-listing-server/node_modules/koa/lib/context.js:97:11) at Object.validate (/Users/leo/VSCodeProjects/极刊登/ji-listing-server/node_modules/egg-validate/app/extend/context.js:14:17) at UserController.deleteUser (/Users/leo/VSCodeProjects/极刊登/ji-listing-server/app/controller/user.js:106:15) at Object.callFn (/Users/leo/VSCodeProjects/极刊登/ji-listing-server/node_modules/egg-core/lib/utils/index.js:36:21) at Object.classControllerMiddleware (/Users/leo/VSCodeProjects/极刊登/ji-listing-server/node_modules/egg-core/lib/loader/mixin/controller.js:87:20) at Object.callFn (/Users/leo/VSCodeProjects/极刊登/ji-listing-server/node_modules/egg-core/lib/utils/index.js:36:21) at wrappedController (/Users/leo/VSCodeProjects/极刊登/ji-listing-server/node_modules/egg-core/lib/utils/router.js:322:18) at dispatch (/Users/leo/VSCodeProjects/极刊登/ji-listing-server/node_modules/koa-router/node_modules/koa-compose/index.js:44:32) at next (/Users/leo/VSCodeProjects/极刊登/ji-listing-server/node_modules/koa-router/node_modules/koa-compose/index.js:45:18) at /Users/leo/VSCodeProjects/极刊登/ji-listing-server/node_modules/koa-router/lib/router.js:346:16 at dispatch (/Users/leo/VSCodeProjects/极刊登/ji-listing-server/node_modules/koa-router/node_modules/koa-compose/index.js:44:32) at /Users/leo/VSCodeProjects/极刊登/ji-listing-server/node_modules/koa-router/node_modules/koa-compose/index.js:36:12 at dispatch (/Users/leo/VSCodeProjects/极刊登/ji-listing-server/node_modules/koa-router/lib/router.js:351:31) at dispatch (/Users/leo/VSCodeProjects/极刊登/ji-listing-server/node_modules/koa-compose/index.js:42:32) at /Users/leo/VSCodeProjects/极刊登/ji-listing-server/app/middleware/jwt.js:30:17 at process._tickCallback (internal/process/next_tick.js:68:7) message: 'Validation Failed', code: 'invalid_param', errors: [ { message: 'should be one of 3', code: 'invalid', field: 'userRole' } ] }
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.