You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
623 B
23 lines
623 B
import { NextApiHandler, NextApiRequest, NextApiResponse } from 'next'; |
|
|
|
import getAllAnvil from './getAllAnvil'; |
|
import handleAPIFakeGetAllAnvil from './handleAPIFakeGetAllAnvil'; |
|
|
|
const handleAPIGetAllAnvil: NextApiHandler<AnvilList> = async ( |
|
request: NextApiRequest, |
|
response: NextApiResponse<AnvilList>, |
|
): Promise<void> => { |
|
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;
|
|
|