From c4a8e21b4ddfe15ff07f504208026823b24af3ea Mon Sep 17 00:00:00 2001 From: wonderlandpark Date: Sun, 23 May 2021 09:16:57 +0900 Subject: [PATCH] feat: added query aliases --- pages/api/v2/search/bots.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pages/api/v2/search/bots.ts b/pages/api/v2/search/bots.ts index 80a3240..149f98d 100644 --- a/pages/api/v2/search/bots.ts +++ b/pages/api/v2/search/bots.ts @@ -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 } }