Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: egg style && upgrade to 2 #19

Merged
merged 2 commits into from
Dec 1, 2017
Merged

feat: egg style && upgrade to 2 #19

merged 2 commits into from
Dec 1, 2017

Conversation

atian25
Copy link
Contributor

@atian25 atian25 commented Dec 1, 2017

egg 升级为 2.0

插件升级

升级 egg 2.0 基本上是无痛的,一行代码修改依赖即可。

但由于 egg-mongoose 这个插件很早前 BREAK 过,所以对应的代码要改下:

@wuomzfx
Copy link
Contributor

wuomzfx commented Dec 1, 2017

非常感谢~!可以升级node8; yield -> await 后续我再修改好了

@atian25
Copy link
Contributor Author

atian25 commented Dec 1, 2017

egg 2 其实是 break change 的,虽然我们尽可能兼容了,但有一些插件不一定会支持。

这个项目没有测试,所以我也没办法保证全部改对了,可能你们要自己测试下。

另外,几个建议:

  • 部署那块,可以不用 pm2 的,直接用我们的 egg-scripts 即可。https://eggjs.org/zh-cn/core/deployment.html#部署
  • 升级 node 8, yield -> await
  • Controller 和 Service 的代码风格改为 class 的方式
  • docker 化,现在的 make 脚本其实不太好用。

@wuomzfx
Copy link
Contributor

wuomzfx commented Dec 1, 2017

嗯,再次感谢建议~ pm2主要是我们内网有另外几个node服务,统一用了pm2做管理,后续再补上egg-scripts。

@wuomzfx wuomzfx merged commit 8a8dba5 into DXY-F2E:dev Dec 1, 2017
@atian25 atian25 deleted the egg-fix branch December 1, 2017 03:19
@wuomzfx
Copy link
Contributor

wuomzfx commented Dec 1, 2017

@atian25 如果controller 改为纯class方式声明,要自定义controller基类的话,也应该是先声明一个基类,再在其他具体controller文件中引用此基类再继承它。像这样:

// 基类 abstract.js

const Controller = require('egg').Controller
class AbstractController extends Controller {
  success (data) {
    this.ctx.status = 200
    this.ctx.body = data
  }
}
module.exports = AbstractController


// 某具体controller ,user.js
 
const AbstractController = require('./abstract')
class UserController extends AbstractController {
  async create () {
    // code
  }
}
module.exports = UserController

而egg 自定义基类文档中貌似还是按之前启动自定义的方式。

@atian25
Copy link
Contributor Author

atian25 commented Dec 1, 2017

eggjs/egg#1771

这里可以先这样下,这块还在讨论。

wangqiang0121 pushed a commit to wangqiang0121/api-mocker that referenced this pull request Mar 14, 2019
wangqiang0121 pushed a commit to wangqiang0121/api-mocker that referenced this pull request Mar 14, 2019
feat: 添加优化相关修改

Closes DXY-F2E#39, DXY-F2E#21, DXY-F2E#38, DXY-F2E#25, DXY-F2E#19, and DXY-F2E#33

See merge request f2e/api-mocker!12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

对依赖引入的建议
2 participants