api-endpoint
Creates Next.js API routes with Firebase. Use when adding GET/POST/PATCH/DELETE endpoints, implementing pagination, adding auth checks, or handling file uploads. Includes route templates and error handling.
When & Why to Use This Skill
This Claude skill streamlines the development of Next.js API routes integrated with Firebase. It automates the creation of secure, production-ready REST endpoints by providing structured templates for CRUD operations, multi-layer security checks, and standardized error handling, significantly accelerating backend development workflows.
Use Cases
- Developing secure GET, POST, PATCH, and DELETE endpoints for Next.js applications using Firebase as the backend.
- Implementing robust security layers including rate limiting, authentication verification, and data validation for protected API routes.
- Managing complex data requirements such as server-side pagination and secure file upload handling within the Next.js App Router.
- Standardizing API response structures and error messages to ensure consistent communication between the frontend and backend.
| name | api-endpoint |
|---|---|
| description | Creates Next.js API routes with Firebase. Use when adding GET/POST/PATCH/DELETE endpoints, implementing pagination, adding auth checks, or handling file uploads. Includes route templates and error handling. |
API Endpoint Skill
Instructions
- Create routes in
src/app/api/following REST conventions - Apply security layers: Rate Limiting → Auth → Validation → Business Logic
- Use
verifyAuthfor protected routes - Use
validateString,validateUrlfromsecurity-utils.ts - Return Korean error messages with proper HTTP status codes
Quick Start
import { NextRequest, NextResponse } from 'next/server'
import { verifyAuth } from '@/lib/auth-utils'
import { validateString, CONTENT_LIMITS } from '@/lib/security-utils'
import { checkRateLimit, getClientIdentifier, RATE_LIMIT_CONFIGS } from '@/lib/rate-limiter'
export async function POST(request: NextRequest) {
// 1. Rate limiting
const clientIp = getClientIdentifier(request)
const { allowed } = checkRateLimit(clientIp, RATE_LIMIT_CONFIGS.AUTHENTICATED_WRITE)
if (!allowed) return NextResponse.json({ error: '요청이 너무 많습니다.' }, { status: 429 })
// 2. Auth
const authUser = await verifyAuth(request)
if (!authUser) return NextResponse.json({ error: '인증이 필요합니다.' }, { status: 401 })
// 3. Validate & process...
}
For complete templates (dynamic routes, pagination, file upload, toggle endpoints), see reference.md.