Files
ZYZ/web-server/app/middleware/checkMainten.ts
2021-11-29 16:19:47 +08:00

23 lines
734 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);
if (isWhiteList) {
await next();
} else {
ctx.body = ctx.service.utils.resResult(STATUS.SERVER_MAINTENANCE);
return;
}
}
}
await next();
};
};