feat: added query aliases

This commit is contained in:
wonderlandpark 2021-05-23 09:16:57 +09:00
parent 435ef2ddf6
commit c4a8e21b4d

View File

@ -8,7 +8,7 @@ import { SearchQuerySchema } from '@utils/Yup'
import { BotList } from '@types'
const SearchBots = RequestHandler().get(async (req: ApiRequest, res: NextApiResponse) => {
const validated = await SearchQuerySchema.validate({ q: req.query.q, page: req.query.page })
const validated = await SearchQuerySchema.validate({ q: req.query.q || req.query.query, page: req.query.page })
.then(el => el)
.catch(e => {
ResponseWrapper(res, { code: 400, errors: e.errors })
@ -30,7 +30,8 @@ const SearchBots = RequestHandler().get(async (req: ApiRequest, res: NextApiResp
interface ApiRequest extends NextApiRequest {
query: {
q: string
q?: string
query?: string
page: string
}
}