27 lines
1.0 KiB
TypeScript
27 lines
1.0 KiB
TypeScript
// import { NextRequest, NextResponse } from "next/server";
|
|
// import { z } from 'zod';
|
|
// import prisma from "@/prisma/client";
|
|
|
|
// // validate the request with zod
|
|
// const createIssueSchema = z.object({
|
|
// title: z.string().min(1).max(255), // confirms string is between 1-255 characters
|
|
// description: z.string().min(1), // confirms string has min length of 1
|
|
// });
|
|
|
|
// // send request
|
|
// export async function POST(request: NextRequest) {
|
|
// // return request with a promise
|
|
// const body = await request.json();
|
|
|
|
// // validate the data
|
|
// const validation = createIssueSchema.safeParse(body);
|
|
// if (!validation.success)
|
|
// return NextResponse.json(validation.error.errors, {status: 400}) // Send error 400 if data is invalid
|
|
|
|
// const newIssue = await prisma.issue.create({
|
|
// data: { title: body.title, description: body.description }
|
|
// });
|
|
|
|
// // return the issue to the client
|
|
// return NextResponse.json(newIssue, {status: 201}); // status 201 means an object was created
|
|
// }
|