注册账号登录
关注

小度鱼系统部署问题

小度鱼问题反馈创建于4月29日66次阅读
  • 这个mongodb的输出是连接成功了吗?

  • api的配置文件,只能配置没有密码的mongodb连接吗?没看到配置用户密码这一项

  • 还有debug的时候注册用户验证吗收不到,怎么注册用户?

Starting child process with 'node ./dist/src/index.js'
Watching directory '/Users/wyp/Desktop/git/xiaoduyu/api.xiaoduyu.com' for changes.
Press rs for restarting the process.
server started on port 3000
Mongoose: accounts.createIndex({ email: 1 }, { unique: true, background: true })
Mongoose: oauths.createIndex({ openid: 1 }, { unique: true, background: true })
Mongoose: comments.createIndex({ posts_id: 1, parent_id: 1, deleted: 1, weaken: 1 }, { background: true })
Mongoose: likes.createIndex({ user_id: 1, type: 1, target_id: 1, mood: 1 }, { unique: true, background: true })
Mongoose: notifications.createIndex({ sender_id: 1, addressee_id: 1, target: 1, type: 1 }, { unique: true, background: true })
Mongoose: usernotifications.createIndex({ addressee_id: 1, has_read: 1, deleted: 1, type: 1 }, { background: true })
Mongoose: captchas.createIndex({ create_at: 1 }, { expireAfterSeconds: 900, background: true })
Mongoose: posts.createIndex({ _id: 1, deleted: 1, weaken: 1, last_comment_at: -1 }, { background: true })
Mongoose: topics.createIndex({ name: 1 }, { unique: true, background: true })
Mongoose: follows.createIndex({ user_id: 1, posts_id: 1, topic_id: 1, people_id: 1 }, { unique: true, background: true })
Mongoose: tokens.createIndex({ create_at: 1 }, { expireAfterSeconds: 2592000, background: true })
Mongoose: phones.createIndex({ phone: 1 }, { unique: true, background: true })
Mongoose: blocks.createIndex({ user_id: 1, posts_id: 1, comment_id: 1, people_id: 1 }, { unique: true, background: true })
Mongoose: feeds.createIndex({ user_id: 1, topic_id: 1, posts_id: 1, comment_id: 1 }, { unique: true, background: true })
Mongoose: messages.createIndex({ user_id: 1, addressee_id: 1, create_at: -1 }, { background: true })
Mongoose: sessions.createIndex({ user_id: 1, addressee_id: 1 }, { unique: true, background: true })
Mongoose: lives.createIndex({ user_id: 1 }, { unique: true, background: true })
1条评论 / 3条回复
debug模式下,验证码会在轻提醒的错误中直接显示。

然后这里配置连接数据库
https://github.com/54sword/api.xiaoduyu.com/blob/master/config/index.default.ts#L93

连接数据中账号密码拼接格式可以查看这里
https://www.runoob.com/mongodb/mongodb-connections.html
回复
我这里点击前端页面,注册用户 获取验证码 无反应
这个是我的配置
if (process.env.NODE_ENV == 'development') {
 config.debug = true;
 // config.mongodbDebug = true;
 config.port = 3000;
 config.mongodbURI = 'mongodb://root:123456@localhost:27017/xiaoduyu';
 config.domain = 'http://localhost';
}

本地是可以连接的


新建数据库是不显示的,需要有插入数据才显示,api那边好像没有初始化数据库,这这边需要手动初始化吗?
或者能告诉我一下我怎么测试web前端和api,api和数据库  他们之间的连接是否正常呢?

下面是mongodb开启debug后弹出的两个错误


OPTIONS /graphql 204 0.372 ms - -
Mongoose: captchas.findOne({ ip: '::1' }, { sort: { create_at: -1 }, projection: { _id: 1 } })
POST /graphql 200 29.481 ms - 8817
OPTIONS /graphql 204 1.039 ms - -
POST /graphql 200 54.079 ms - 64
POST /graphql 200 3.324 ms - 8817
OPTIONS /graphql 204 0.792 ms - -
Mongoose: accounts.findOne({ email: 'yanxiaole_vip@163.com' }, { projection: {} })
Mongoose: captchas.insertOne({ _id: ObjectId("5ea91e933b58bd7672c87e50"), email: 'yanxiaole_vip@163.com', type: 'sign-up', captcha: '389062', create_at: new Date("Wed, 29 Apr 2020 06:28:35 GMT"), __v: 0 }, { session: null })
(node:30322) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'captcha' of undefined
    at /Users/wyp/Desktop/git/xiaoduyu/api.xiaoduyu.com/dist/src/graphql/models/captcha/resolvers.js:191:37
    at Generator.next (<anonymous>)
    at fulfilled (/Users/wyp/Desktop/git/xiaoduyu/api.xiaoduyu.com/dist/src/graphql/models/captcha/resolvers.js:5:58)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:229:7)
(node:30322) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:30322) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
OPTIONS /graphql 204 0.484 ms - -
Mongoose: captchas.findOne({ ip: '::1' }, { sort: { create_at: -1 }, projection: { _id: 1 } })
POST /graphql 200 16.177 ms - 64
OPTIONS /graphql 204 0.439 ms - -
Mongoose: captchas.findOne({ ip: '::1' }, { sort: { create_at: -1 }, projection: { _id: 1 } })
Mongoose: captchas.insertOne({ _id: ObjectId("5ea91ea53b58bd7672c87e51"), ip: '::1', type: 'sign-in', captcha: '463439', create_at: new Date("Wed, 29 Apr 2020 06:28:53 GMT"), __v: 0 }, { session: null })
POST /graphql 200 25.857 ms - 844
Mongoose: captchas.findOne({ ip: '::1' }, { sort: { create_at: -1 }, projection: { _id: 1 } })
POST /graphql 200 9.356 ms - 64
OPTIONS /graphql 204 0.460 ms - -
Mongoose: captchas.findOne({ ip: '::1' }, { sort: { create_at: -1 }, projection: { _id: 1 } })
Mongoose: captchas.insertOne({ _id: ObjectId("5ea91ead3b58bd7672c87e52"), ip: '::1', type: 'sign-in', captcha: '245842', create_at: new Date("Wed, 29 Apr 2020 06:29:01 GMT"), __v: 0 }, { session: null })
POST /graphql 200 19.123 ms - 844
Mongoose: captchas.findOne({ ip: '::1' }, { sort: { create_at: -1 }, projection: { _id: 1 } })
POST /graphql 200 11.200 ms - 64
OPTIONS /graphql 204 0.917 ms - -
OPTIONS /graphql 204 0.340 ms - -
Mongoose: captchas.findOne({ ip: '::1' }, { sort: { create_at: -1 }, projection: { _id: 1 } })
Mongoose: captchas.findOne({ ip: '::1' }, { sort: { create_at: -1 }, projection: { _id: 1 } })
POST /graphql 200 14.819 ms - 64
POST /graphql 200 13.427 ms - 64
OPTIONS /graphql 204 0.314 ms - -
Mongoose: phones.findOne({ phone: '18503836651' }, { projection: {} })
Mongoose: captchas.insertOne({ _id: ObjectId("5ea91ebd3b58bd7672c87e53"), phone: '18503836651', type: 'sign-up', captcha: '359568', create_at: new Date("Wed, 29 Apr 2020 06:29:17 GMT"), __v: 0 }, { session: null })
(node:30322) UnhandledPromiseRejectionWarning: error: 添加失败
    at Object.exports.default (/Users/wyp/Desktop/git/xiaoduyu/api.xiaoduyu.com/dist/src/graphql/common/errors.js:23:12)
    at /Users/wyp/Desktop/git/xiaoduyu/api.xiaoduyu.com/dist/src/graphql/models/captcha/resolvers.js:372:35
    at Generator.next (<anonymous>)
    at fulfilled (/Users/wyp/Desktop/git/xiaoduyu/api.xiaoduyu.com/dist/src/graphql/models/captcha/resolvers.js:5:58)
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:229:7)
(node:30322) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
POST /graphql - - ms - -
POST /graphql - - ms - -
GET /graphql 200 12.104 ms - -
POST /graphql 200 289.110 ms - 165840
POST /graphql 200 200.464 ms - 165840
POST /graphql 200 97.315 ms - 165840
POST /graphql 200 102.888 ms - 165840
POST /graphql 200 111.327 ms - 165840
POST /graphql 200 111.267 ms - 165840
POST /graphql 200 78.864 ms - 165840
POST /graphql 200 64.653 ms - 165840
POST /graphql 400 8.037 ms - 161
POST /graphql 200 73.251 ms - 165840
POST /graphql 200 82.702 ms - 165840
POST /graphql 200 56.029 ms - 165840
POST /graphql 200 60.152 ms - 165840
POST /graphql 200 143.239 ms - 165840
POST /graphql 200 84.254 ms - 165840
POST /graphql 200 73.288 ms - 165840
POST /graphql 200 64.965 ms - 165840
POST /graphql 200 71.682 ms - 165840
POST /graphql 200 90.210 ms - 165840
POST /graphql 200 110.042 ms - 165840
POST /graphql 200 58.090 ms - 165840
POST /graphql 200 38.679 ms - 165840
POST /graphql 200 67.255 ms - 165840
POST /graphql 200 51.867 ms - 165840
POST /graphql 200 63.439 ms - 165840
POST /graphql 200 46.297 ms - 165840
POST /graphql 200 54.374 ms - 165840
POST /graphql 200 47.183 ms - 165840
POST /graphql 200 49.463 ms - 165840
POST /graphql 200 44.510 ms - 165840
POST /graphql 200 79.080 ms - 165840
POST /graphql 200 41.453 ms - 165840
POST /graphql 200 77.182 ms - 165840
POST /graphql 200 69.978 ms - 165840
crashing child
Starting child process with 'node ./dist/src/index.js'
server started on port 3000
POST /graphql 200 198.630 ms - 165840
POST /graphql 200 84.884 ms - 165840
POST /graphql 200 84.074 ms - 165840
POST /graphql 200 67.955 ms - 165840
POST /graphql 200 63.375 ms - 165840
POST /graphql 200 62.379 ms - 165840
POST /graphql 200 59.900 ms - 165840
POST /graphql 400 6.915 ms - 161
POST /graphql 200 73.132 ms - 165840
GET /graphql 200 20.449 ms - -
POST /graphql 200 32.319 ms - 165840
POST /graphql 200 44.554 ms - 165840
POST /graphql 200 78.632 ms - 165840
POST /graphql 400 8.178 ms - 161
POST /graphql 200 61.858 ms - 165840
(node:30386) UnhandledPromiseRejectionWarning: MongoTimeoutError: Server selection timed out after 30000 ms
    at Timeout.setTimeout [as _onTimeout] (/Users/wyp/Desktop/git/xiaoduyu/api.xiaoduyu.com/node_modules/mongodb/lib/core/sdam/topology.js:897:9)
    at ontimeout (timers.js:498:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:290:5)
(node:30386) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:30386) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
POST /graphql 200 53.138 ms - 165840
4月29日
回复
数据库不需要初始化,运行的时候会自动创建。

首先判断api是否正常启动
http://localhost:3000

开发环境api配置,打开此处的注解
https://github.com/54sword/xiaoduyu.com/blob/master/config/index.default.js#L126

线上环境连接api配置
https://github.com/54sword/xiaoduyu.com/blob/master/config/index.default.js#L38
4月29日
回复
折腾了半天,mongodb 的账户密码还是无法读取,这个格式
```
'mongodb://user:pass@localhost:27017/xiaoduyu'
```
一直报下面这个错误,只找到了一个相关的文档:https://stackoverflow.com/questions/54335970/mongoparseerror-unescaped-at-sign-in-authority-section-at-parseconnectionstring

测试后并不行,只能把mongdb认证关闭了,目前已经测试完毕,可以去折腾线上了,感谢@吴世剑 耐心解答问题。

此处是报错
crashing child
Starting child process with 'node ./dist/src/index.js'
server started on port 3000
(node:31910) UnhandledPromiseRejectionWarning: MongoParseError: Unescaped at-sign in authority section
    at parseConnectionString (/Users/wyp/Desktop/git/xiaoduyu/api.xiaoduyu.com/node_modules/mongodb/lib/core/uri_parser.js:549:21)
    at connect (/Users/wyp/Desktop/git/xiaoduyu/api.xiaoduyu.com/node_modules/mongodb/lib/operations/connect.js:268:3)
    at ConnectOperation.execute (/Users/wyp/Desktop/git/xiaoduyu/api.xiaoduyu.com/node_modules/mongodb/lib/operations/connect.js:191:5)
    at executeOperation (/Users/wyp/Desktop/git/xiaoduyu/api.xiaoduyu.com/node_modules/mongodb/lib/operations/execute_operation.js:83:26)
    at MongoClient.connect (/Users/wyp/Desktop/git/xiaoduyu/api.xiaoduyu.com/node_modules/mongodb/lib/mongo_client.js:216:10)
    at Promise (/Users/wyp/Desktop/git/xiaoduyu/api.xiaoduyu.com/node_modules/mongoose/lib/connection.js:632:12)
    at new Promise (<anonymous>)


4月29日
回复
qingfengfenga
关注私信
1
关注
1
粉丝
4
帖子