登录优化:gate可变为短链接
This commit is contained in:
+11
-1
@@ -1,6 +1,7 @@
|
||||
import 'reflect-metadata'
|
||||
import * as mongoose from 'mongoose';
|
||||
import { Application, IBoot } from 'egg';
|
||||
import { connectRedis } from './app/pubUtils/redis';
|
||||
|
||||
export default class FooBoot implements IBoot {
|
||||
private readonly app: Application;
|
||||
@@ -13,7 +14,9 @@ export default class FooBoot implements IBoot {
|
||||
// Ready to call configDidLoad,`
|
||||
// Config, plugin files are referred,`
|
||||
// this is the last chance to modify the config.
|
||||
await this.connectDB(this.app)
|
||||
await this.connectDB(this.app);
|
||||
await this.connectRedis(this.app);
|
||||
|
||||
}
|
||||
|
||||
configDidLoad() {
|
||||
@@ -54,6 +57,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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user