后台:军团管理

This commit is contained in:
luying
2021-12-15 19:54:43 +08:00
parent 05e410d28f
commit 15b9d9f97a
19 changed files with 318 additions and 39 deletions
+9
View File
@@ -2,6 +2,7 @@ import 'reflect-metadata'
import * as mongoose from 'mongoose';
import { Application, IBoot } from 'egg';
import { loadGmDb } from '@db/index';
import { connectRedis } from '@pubUtils/redis';
export default class FooBoot implements IBoot {
private readonly app: Application;
@@ -16,6 +17,7 @@ export default class FooBoot implements IBoot {
// this is the last chance to modify the config.
await this.connectDB(this.app)
await this.connectGMDB(this.app);
await this.connectRedis(this.app);
this.app.config.realEnv = this.app.config.env;
if(this.app.config.env == 'local') {
@@ -78,6 +80,13 @@ export default class FooBoot implements IBoot {
}
}
public async connectRedis(app: Application) {
const { url, pw } = app.config.redis
if (url) {
const redisClient = connectRedis(url, pw);
app.context.redisClient = redisClient;
}
}
//#endregion
}