Local modifications to ClusterLabs/Anvil by Alteeve
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.

32 lines
781 B

import { NextApiHandler, NextApiRequest, NextApiResponse } from 'next';
import getOneAnvil from './getOneAnvil';
import handleAPIFakeGetOneAnvil from './handleAPIFakeGetOneAnvil';
const handleAPIGetOneAnvil: NextApiHandler<AnvilStatus> = async (
request: NextApiRequest,
response: NextApiResponse<AnvilStatus>,
): Promise<void> => {
const {
query: { uuid },
}: NextApiRequest = request;
const anvilUUID: string = uuid instanceof Array ? uuid[0] : uuid;
const { anvilStatus, error }: GetOneAnvilResponse = await getOneAnvil(
anvilUUID,
);
if (error) {
response.status(503);
} else {
response.status(200);
}
response.send(anvilStatus);
};
export default process.env.IS_USE_FAKE_DATA
? handleAPIFakeGetOneAnvil
: handleAPIGetOneAnvil;