web-server 注册、登录、获取服务器列表;game-server token 校验

This commit is contained in:
liangtongchuan
2020-08-19 14:40:11 +08:00
parent 0458817b51
commit 940879016f
32 changed files with 1144 additions and 38 deletions
+58
View File
@@ -0,0 +1,58 @@
import 'reflect-metadata'
import * as mongoose from 'mongoose';
import { Application, IBoot } from 'egg';
export default class FooBoot implements IBoot {
private readonly app: Application;
constructor(app: Application) {
this.app = app;
}
async configWillLoad() {
// Ready to call configDidLoad,`
// Config, plugin files are referred,`
// this is the last chance to modify the config.
await this.connectDB(this.app)
}
configDidLoad() {
// Config, plugin files have loaded.
}
async didLoad() {
// All files have loaded, start plugin here.
}
async willReady() {
// All plugins have started, can do some thing before app ready.
// await this.customLoadModel();
}
async didReady() {
// Worker is ready, can do some things
// don't need to block the app boot.
}
async serverDidReady() {
// Server is listening.
}
async beforeClose() {
// Do some thing before app close.
}
//#region 手动挂载model,测试需要ctx.model
public async connectDB(app: Application) {
const { url, options } = app.config.mongoose
if (url) {
const connection = await mongoose.connect(url, options)
app.context.connection = connection
}
}
//#endregion
}
module.exports = FooBoot;