insertVessel.ts (17.06.2024)
Sun Jun 16 2024 23:05:27 GMT+0000 (Coordinated Universal Time)
Saved by
@rafal_rydz
import type { NextApiRequest, NextApiResponse } from "next";
import { insertVessel } from "@/lib/db";
export default async function handler(
req: NextApiRequest,
res: NextApiResponse,
) {
if (req.method === "POST") {
try {
const result = await insertVessel(req.body);
return res.status(200).json({ success: true, data: result });
} catch (error) {
return res.status(500).json({ success: false, error: error.message });
}
} else {
res.setHeader("Allow", ["POST"]);
return res
.status(405)
.send(`Method ${req.method ?? "Undefined"} Not Allowed`);
}
}
content_copyCOPY
Comments