import { NextApiHandler, NextApiRequest, NextApiResponse } from 'next'; import getAllAnvil from './getAllAnvil'; import handleAPIFakeGetAllAnvil from './handleAPIFakeGetAllAnvil'; const handleAPIGetAllAnvil: NextApiHandler = async ( request: NextApiRequest, response: NextApiResponse, ): Promise => { const { anvilList, error }: GetAllAnvilResponse = await getAllAnvil(); if (error) { response.status(503); } else { response.status(200); } response.send(anvilList); }; export default process.env.IS_USE_FAKE_DATA ? handleAPIFakeGetAllAnvil : handleAPIGetAllAnvil;