Files
ZYZ/web-server/app/middleware/checkMainten.ts
2021-07-16 15:39:36 +08:00

23 lines
744 B
TypeScript

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 = await 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();
};
};