xiaohongshu
xiaohongshu
api-route-scaffold
Create new Next.js API routes following project patterns. Use when user mentions "new endpoint", "add API", "create route", or "POST/GET handler".
Full skill instructions
This project uses Next.js 16 App Router with a consistent API pattern across all routes.
Create route file: app/api/<endpoint-name>/route.ts
Use this template:
import { NextRequest, NextResponse } from 'next/server';
// CORS headers for cross-origin requests
const corsHeaders = {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',
};
export async function OPTIONS() {
return NextResponse.json(null, { headers: corsHeaders });
}
export async function POST(req: NextRequest) {
try {
const { /* destructure fields */ } = await req.json();
// Input validation
if (!requiredField) {
return NextResponse.json(
{ error: 'Field is required' },
{ status: 400, headers: corsHeaders }
);
}
// Check required environment variables
const apiKey = process.env.YOUR_API_KEY;
if (!apiKey) {
console.error('YOUR_API_KEY is not configured');
return NextResponse.json(
{ error: 'YOUR_API_KEY is not configured' },
{ status: 500, headers: corsHeaders }
);
}
// Business logic here
const result = await doSomething();
return NextResponse.json({ result }, { headers: corsHeaders });
} catch (error) {
console.error('Error in endpoint:', error);
return NextResponse.json(
{ error: error instanceof Error ? error.message : 'Unknown error' },
{ status: 500, headers: corsHeaders }
);
}
}
const HANDLE_REGEX = /^[a-zA-Z0-9_]{1,15}$/;
if (!handle || !HANDLE_REGEX.test(handle)) {
return NextResponse.json(
{ error: 'Invalid X handle format.' },
{ status: 400, headers: corsHeaders }
);
}
@/db:import { db, tableName } from '@/db';
import { eq, gt, and } from 'drizzle-orm';
| Endpoint | Method | Purpose |
|---|---|---|
/api/analyze-account | POST | Analyze X account with Grok |
/api/generate-image | POST | Generate images (rate-limited) |
/api/roast-account | POST | Generate roast letter |
/api/fbi-profile | POST | Generate FBI profile |
app/api/user-stats/route.tsapp/api/health/route.ts with GET handlerxiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience