pixelass's picture
feat: initial prototype
a86df80 unverified
raw
history blame
525 Bytes
import { toOpenAI } from "@/services/api";
import { NextApiRequest, NextApiResponse } from "next";
import { AxiosError } from "axios";
export default async function handler(request: NextApiRequest, response: NextApiResponse) {
switch (request.method) {
case "POST":
try {
const answer = await toOpenAI(request.body);
return response.status(200).json(answer);
} catch (error) {
return response.status((error as AxiosError).status ?? 500).end();
}
default:
return response.status(405).end();
}
}