원클릭으로
create-api-endpoints
Use when creating new Next.js route handlers using the custom helper wrapper.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Use when creating new Next.js route handlers using the custom helper wrapper.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Use when adding a brand-new CRUD resource beyond the core entity (e.g. a second model the PS requires).
Use when building or restyling any page or component.
Use when constructing forms, inputs, submit behaviors, validation displays, and feedback toast alerts.
Use whenever the Prisma schema changes and a migration is needed.
Use when integrating third-party APIs (e.g. SMTP emails, SMS notification gateways, payment checkout gates, or OCR parsers).
Use when adapting the template's placeholder Item entity to a hackathon problem statement's actual domain entity.
| name | create-api-endpoints |
| description | Use when creating new Next.js route handlers using the custom helper wrapper. |
To build route handlers quickly and securely without writing boilerplate validation or session-guard blocks, use the custom createApiRoute helper located in src/lib/api.ts.
Import the Helper & Zod:
import { createApiRoute } from "@/lib/api";
import { z } from "zod";
import { prisma } from "@/lib/prisma";
Define the Route Handler:
Wrap your execution inside createApiRoute. You can specify guards and parse schemas:
export const POST = createApiRoute({
requireAuth: true, // Optional: set true to force user login
requireAdmin: false, // Optional: set true to restrict to ADMIN role
schema: z.object({ // Optional: parses and validates JSON body
amount: z.number().positive(),
description: z.string().min(3)
}),
handler: async (req, { session, body, params }) => {
// Request body is parsed and typed
// Session details are guaranteed to be active
const newRecord = await prisma.item.create({
data: {
title: body.description,
category: "LOGS",
ownerId: session.user.id
}
});
// Simply return your database result object.
// The wrapper automatically sends status 200 with JSON payload.
return newRecord;
}
});
Exception Handling:
Do not wrap the inner handler in extensive try/catch blocks unless you want custom responses. The wrapper intercepts database errors and returns a formatted 500 Internal Server Error automatically.