mirror of
https://github.com/koreanbots/core.git
synced 2025-12-16 06:20:24 +00:00
feat: added get bot api
This commit is contained in:
parent
75164875f4
commit
aaf7edbb60
19
pages/api/v2/bots/[id].ts
Normal file
19
pages/api/v2/bots/[id].ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { get } from '@utils/Query'
|
||||||
|
import ResponseWrapper from '@utils/ResponseWrapper'
|
||||||
|
import { NextApiRequest, NextApiResponse } from 'next'
|
||||||
|
import nc from 'next-connect'
|
||||||
|
|
||||||
|
const BotInfo = nc<ApiRequest, NextApiResponse>()
|
||||||
|
.get(async(req, res) => {
|
||||||
|
const bot = await get.bot.load(req.query.id)
|
||||||
|
if(!bot) return ResponseWrapper(res, { code: 404, message: '존재하지 않는 봇입니다.' })
|
||||||
|
else return ResponseWrapper(res, { code: 200, data: bot })
|
||||||
|
})
|
||||||
|
|
||||||
|
interface ApiRequest extends NextApiRequest {
|
||||||
|
query: {
|
||||||
|
id: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default BotInfo
|
||||||
Loading…
x
Reference in New Issue
Block a user