用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/dev-hann/song --skill api-route-development命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Runs PM-Designer-Doc triple review protocol to reach consensus on feature specs before implementation. Includes domain documentation consistency check. Use before implementing any new screen, component, or significant feature.
Create Server and Client React components with proper props, state, and patterns
Enforce docs ↔ code consistency before and after implementation. Launches doc-reviewer agent to cross-check domain documentation against actual codebase, detects drift, and ensures documentation updates accompany code changes.
基于 SOC 职业分类
正在显示 SKILL.md
| name | api-route-development |
| description | Create API routes with proper validation and error handling for Next.js App Router (Node.js runtime) |
| license | MIT |
| compatibility | opencode |
| metadata | {"category":"development","complexity":"intermediate"} |
async params (Next.js 16 requirement)server/ directoryUse this when you need to:
I'll ask clarifying questions if:
This project uses Node.js runtime (default) — not Edge Runtime.
This is required because we use better-sqlite3 (native Node.js module).
// DO NOT add this line:
// export const runtime = 'edge';
// Node.js runtime is the default, no declaration needed.
// This allows using: better-sqlite3, fs, path, etc.
import { NextRequest, NextResponse } from 'next/server';
import { SearchParamsSchema } from '@/server/schemas/search';
import { searchVideos } from '@/server/models/search';
export async function GET(request: NextRequest) {
try {
const { searchParams } = new URL(request.url);
const queryParams = Object.fromEntries(searchParams);
const paramsResult = SearchParamsSchema.safeParse(queryParams);
if (!paramsResult.success) {
return NextResponse.json(
{ error: paramsResult.error.errors[0].message },
{ status: 400 }
);
}
const { q, filter } = paramsResult.data;
const results = await searchVideos(q, filter);
return NextResponse.json(results);
} (error) {
.(, error);
.(
{ : },
{ : }
);
}
}
import { NextRequest, NextResponse } from 'next/server';
export async function GET(
request: NextRequest,
{ params }: { params: Promise<{ id: string }> }
) {
const { id } = await params;
if (!id) {
return NextResponse.json(
{ error: 'ID parameter is required' },
{ status: 400 }
);
}
const data = await fetchData(id);
return NextResponse.json(data);
}
import { NextRequest, NextResponse } from 'next/server';
import { CreatePlaylistSchema } from '@/server/schemas/playlist';
import { createPlaylist } from '@/server/models/playlist';
export async function POST(request: NextRequest) {
try {
const body = await request.json();
const validationResult = CreatePlaylistSchema.safeParse(body);
if (!validationResult.success) {
return NextResponse.json(
{ error: validationResult.error.errors[0].message },
{ status: 400 }
);
}
const playlistData = validationResult.data;
const result = createPlaylist(playlistData);
return NextResponse.json(result, { status: 201 });
} catch (error) {
console.error(, error);
.(
{ : },
{ : }
);
}
}
Protected routes are automatically enforced by proxy.ts.
No auth check needed in the route handler itself — just use the session:
import { auth } from '@/server/auth';
import { NextRequest, NextResponse } from 'next/server';
export async function GET(request: NextRequest) {
const session = await auth();
if (!session?.user?.id) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
}
const userId = session.user.id;
const data = await getUserData(userId);
return NextResponse.json(data);
}
// 400 Bad Request (validation error)
return NextResponse.json({ error: 'message' }, { status: 400 });
// 401 Unauthorized
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
// 404 Not Found
return NextResponse.json({ error: 'Not found' }, { status: 404 });
// 500 Internal Server Error
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
import { NextRequest, NextResponse } from 'next/server';
import { auth } from '@/server/auth';
import type { Audio, Playlist } from '@/types';
async params — { params }: { params: Promise<{ id: string }> }@/server/*export async function GET)export const runtime = 'edge' — this breaks better-sqlite3params without await (Next.js 16)server/