● 200 OKapi/orders/route.ts
// an order endpoint, written the way I write them
export async function POST(req: Request) {
const body = orderSchema.parse(await req.json());
const user = await requireSession(req);
const order = await db.$transaction(async (tx) => {
const o = await tx.order.create({ data: { ...body, userId: user.id } });
await tx.stock.decrement(o.items);
return o;
});
await queue.enqueue("invoice.generate", { orderId: order.id });
return Response.json(order, { status: 201 });
}04 — Backend
Infrastructure you can still build on a year from now
I write the database, authentication, APIs and automations so that when your business grows, none of it has to be rebuilt. Safe transactions, input validation and background job queues, from the first version.
A custom admin panel for your content
User accounts, roles and permission levels
Payment and SMS service integrations
AI automation for repetitive work
See real projects