|
1 | 1 | import { beanInformationFormSchema } from "@/lib/beanconqueror/validations/bean-information-form-schema"; |
2 | | -import { ZodIssue } from "zod"; |
3 | 2 | import { createUrlFromFormSchema } from "@/lib/beanconqueror/proto/proto-helpers"; |
4 | 3 | import { NextResponse } from "next/server"; |
5 | 4 | import { getBeanLink } from "@/lib/beanlink"; |
6 | 5 |
|
7 | | -export async function GET() { |
| 6 | +export function GET() { |
8 | 7 | return NextResponse.json({ |
9 | 8 | example: { |
10 | 9 | "coffeeName": "Ethiopian Yirgacheffe", |
@@ -39,25 +38,22 @@ export async function GET() { |
39 | 38 | } |
40 | 39 | ] |
41 | 40 | } |
42 | | - }) |
| 41 | + }); |
43 | 42 | } |
44 | 43 |
|
45 | | -export async function POST( |
46 | | - req: Request, |
47 | | -) { |
48 | | - const json = await req.json() |
49 | | - const body = beanInformationFormSchema.safeParse(json) |
| 44 | +export async function POST(req: Request) { |
| 45 | + const body = beanInformationFormSchema.safeParse((await req.json())); |
50 | 46 |
|
51 | 47 | if (!body.success) { |
52 | | - const { errors } = body.error |
| 48 | + const { errors } = body.error; |
53 | 49 |
|
54 | 50 | return NextResponse.json({ |
55 | 51 | error: { message: "Invalid request data", errors } |
56 | | - }, { status: 400 }) |
| 52 | + }, { status: 400 }); |
57 | 53 | } |
58 | 54 |
|
59 | | - const beanconquerorUrl = createUrlFromFormSchema(body.data) |
60 | | - const beanLink = await getBeanLink(beanconquerorUrl) |
| 55 | + const beanconquerorUrl = createUrlFromFormSchema(body.data); |
| 56 | + const beanLink = await getBeanLink(beanconquerorUrl); |
61 | 57 |
|
62 | | - return NextResponse.json({ qr: beanLink }) |
| 58 | + return NextResponse.json({ qr: beanLink }); |
63 | 59 | } |
0 commit comments