如何让应用的configWillLoad在egg-sequelize建立连接之前执行
- Dominant language
- TypeScript
- Stars
- 19k
- Forks
- 1.8k
- PR merge metrics
- No merged PRs in 30d
Description
## 相关环境信息
- **Egg 版本**:2.27.0
需求是这样的,在sequelize初始化之前,修改配置文件里的加密密码
我的应用`app.js`是这样的
```js
class AppBoot{
constructor(app){
this.app = app;
this.ctx = app.createAnonymousContext();
}
configWillLoad(){
const {
sequelize,
redis
} = this.app.config;
const base64Reg = /^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$/;
const mysqlPwd = sequelize.password;
if(mysqlPwd && base64Reg.test(mysqlPwd)) sequelize.password = this.ctx.helper.decryptPwd(mysqlPwd);
if(redis.client && redis.client.password && base64Reg.test(redis.client.password)){
const redisPwd = redis.client.password;
redis.client.password = this.ctx.helper.decryptPwd(redisPwd);
}
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.