Web, mobile, ERP, and AI-powered applications built around your workflows.
Our engineering teams build custom web applications, mobile apps, ERP/CRM platforms, and AI-driven products, architected for scale from day one and delivered with modern DevOps practices.
| 1 | import { NextResponse } from "next/server"; |
| 2 | import { z } from "zod"; |
| 3 | import { db } from "@/lib/db"; |
| 4 | |
| 5 | const OrderSchema = z.object({ |
| 6 | customerId: z.string().uuid(), |
| 7 | items: z.array( |
| 8 | z.object({ sku: z.string(), quantity: z.number().min(1) }) |
| 9 | ), |
| 10 | }); |
| 11 | |
| 12 | export async function POST(request: Request) { |
| 13 | const body = await request.json(); |
| 14 | const result = OrderSchema.safeParse(body); |
| 15 | |
| 16 | if (!result.success) { |
| 17 | return NextResponse.json( |
| 18 | { error: "Invalid order payload" }, |
| 19 | { status: 422 } |
| 20 | ); |
| 21 | } |
| 22 | |
| 23 | const order = await db.orders.create({ |
| 24 | data: result.data, |
| 25 | }); |
| 26 | |
| 27 | // Notify downstream fulfillment service |
| 28 | await queue.publish("order.created", order); |
| 29 | |
| 30 | return NextResponse.json(order, { status: 201 }); |
| 31 | } |
Talk to a specialist about your digital transaformation needs — no pressure, just a clear plan forward.
Start Your Project