系统:停服维护逻辑
This commit is contained in:
22
web-server/app/middleware/checkMainten.ts
Normal file
22
web-server/app/middleware/checkMainten.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { STATUS } from '@consts';
|
||||
import { checkWhiteList } from 'app/pubUtils/util';
|
||||
|
||||
module.exports = () => {
|
||||
return async function checkMainten(ctx, next) {
|
||||
const { serverId } = ctx.request.body;
|
||||
if (serverId) {
|
||||
let maintenServers = ctx.service.game.getServerMainten();
|
||||
if (maintenServers.indexOf(serverId) != -1) {
|
||||
let isWhiteList = await checkWhiteList(ctx.tel, ctx.request.ip, ctx.auth);
|
||||
if (isWhiteList) {
|
||||
await next();
|
||||
} else {
|
||||
ctx.body = ctx.service.utils.resResult(STATUS.SERVER_MAINTENANCE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
await next();
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user