mirror of
https://github.com/koreanbots/core.git
synced 2025-12-16 06:20:24 +00:00
fix: version for v1
This commit is contained in:
parent
05b92d1980
commit
62ce9c155b
@ -10,7 +10,7 @@ const limiter = rateLimit({
|
|||||||
windowMs: 60 * 1000,
|
windowMs: 60 * 1000,
|
||||||
max: 1,
|
max: 1,
|
||||||
statusCode: 429,
|
statusCode: 429,
|
||||||
handler: (_req, res) => ResponseWrapper(res, { code: 429 }),
|
handler: (_req, res) => ResponseWrapper(res, { code: 429, version: 1 }),
|
||||||
keyGenerator: (req) => req.headers.authorization,
|
keyGenerator: (req) => req.headers.authorization,
|
||||||
skip: (req, res) => {
|
skip: (req, res) => {
|
||||||
res.removeHeader('X-RateLimit-Global')
|
res.removeHeader('X-RateLimit-Global')
|
||||||
@ -23,7 +23,7 @@ const BotStats = RequestHandler()
|
|||||||
.post(limiter)
|
.post(limiter)
|
||||||
.post(async (req: PostApiRequest, res) => {
|
.post(async (req: PostApiRequest, res) => {
|
||||||
const bot = await get.BotAuthorization(req.headers.token)
|
const bot = await get.BotAuthorization(req.headers.token)
|
||||||
if(!bot) return ResponseWrapper(res, { code: 401 })
|
if(!bot) return ResponseWrapper(res, { code: 401, version: 1 })
|
||||||
const validated: BotStatUpdate = await BotStatUpdateSchema.validate(req.body, { abortEarly: false })
|
const validated: BotStatUpdate = await BotStatUpdateSchema.validate(req.body, { abortEarly: false })
|
||||||
.then(el => el)
|
.then(el => el)
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
@ -33,11 +33,11 @@ const BotStats = RequestHandler()
|
|||||||
|
|
||||||
if(!validated) return
|
if(!validated) return
|
||||||
const botInfo = await get.bot.load(bot)
|
const botInfo = await get.bot.load(bot)
|
||||||
if(!botInfo) return ResponseWrapper(res, { code: 404, message: '존재하지 않는 봇입니다.' })
|
if(!botInfo) return ResponseWrapper(res, { code: 404, message: '존재하지 않는 봇입니다.', version: 1 })
|
||||||
if(botInfo.id !== bot) return ResponseWrapper(res, { code: 403 })
|
if(botInfo.id !== bot) return ResponseWrapper(res, { code: 403, version: 1 })
|
||||||
const d = await update.updateServer(botInfo.id, validated.servers)
|
const d = await update.updateServer(botInfo.id, validated.servers)
|
||||||
if(d===1 || d===2) return ResponseWrapper(res, { code: 403, message: `서버 수를 ${[null, '1만', '100만'][d]} 이상으로 설정하실 수 없습니다. 문의해주세요.` })
|
if(d===1 || d===2) return ResponseWrapper(res, { code: 403, message: `서버 수를 ${[null, '1만', '100만'][d]} 이상으로 설정하실 수 없습니다. 문의해주세요.`, version: 1 })
|
||||||
return ResponseWrapper(res, { code: 200, message: '성공적으로 업데이트 했습니다.'})
|
return ResponseWrapper(res, { code: 200, message: '성공적으로 업데이트 했습니다.', version: 1 })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user