Skip to content

Commit

Permalink
change impl
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaslagoni committed Oct 26, 2023
1 parent af1d0a3 commit 9f5461d
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions modelina-website/src/pages/api/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,23 @@ export async function generateNewCode(message: GenerateMessage): Promise<UpdateM
/**
* Next specific API function, why export default is necessary. Called when running locally.
*/
export default async function generate(req: NextApiRequest, res: NextApiResponse) {
try {
const message: GenerateMessage = JSON.parse(req.body);
const response = await generateNewCode(message);
if (Object.keys(response).includes('models') && Object.values(response).length > 0) {
return res.status(200).json(response);
}
else {
throw new Error("Input is not an correct AsyncAPI document so it cannot be processed.");
}
} catch (e : any) {
console.error(e);
return res.status(500).json({
error: e.message
});
}
}
// export default async function generate(req: NextApiRequest, res: NextApiResponse) {
// try {
// const message: GenerateMessage = JSON.parse(req.body);
// const response = await generateNewCode(message);
// if (Object.keys(response).includes('models') && Object.values(response).length > 0) {
// return res.status(200).json(response);
// }
// else {
// throw new Error("Input is not an correct AsyncAPI document so it cannot be processed.");
// }
// } catch (e : any) {
// console.error(e);
// return res.status(500).json({
// error: e.message
// });
// }
// }

/**
* Netlify function specific code, can be ignored in local development.
Expand Down Expand Up @@ -110,4 +110,4 @@ const handler: Handler = async (event: HandlerEvent) => {
};
}
}
export { handler };
export { handler as default };

0 comments on commit 9f5461d

Please sign in to comment.