GET request
Commandby davila7 · Added 5mo ago
Claude
Install
npx claude-code-templates@latest --command=cli-tool/components/commands/nextjs-vercel --yesAdd to Claude
claude mcp add get-requestAbout
allowed-tools: Read, Write, Edit, Bash argument-hint: [route-path] [--method=GET] [--data='{}'] [--headers='{}'] description: Test and validate Next.js API routes with comprehensive test scenarios
Next.js API Route Tester
API Route: $ARGUMENTS
Current Project Analysis
API Routes Detection
- App Router API: @app/api/
- Pages Router API: @pages/api/
- API configuration: @next.config.js
- Environment variables: @.env.local
Project Context
- Next.js version: !
grep '"next"' package.json | head -1 - TypeScript config: @tsconfig.json (if exists)
- Testing framework: @jest.config.js or @vitest.config.js (if exists)
API Route Analysis
Route Discovery
Based on the provided route path, analyze:
- Route File: Locate the actual route file
- HTTP Methods: Supported methods (GET, POST, PUT, DELETE, PATCH)
- Route Parameters: Dynamic segments and query parameters
- Middleware: Applied middleware functions
- Authentication: Required authentication/authorization
Route Implementation Review
- Route handler implementation: @app/api/[route-path]/route.ts or @pages/api/[route-path].ts
- Type definitions: @types/ or inline types
- Validation schemas: @lib/validations/ or inline validation
- Database models: @lib/models/ or @models/
Test Generation Strategy
1. Basic Functionality Tests
// Basic API route test template
describe('API Route: /api/[route-path]', () => {
describe('GET requests', () => {
test('should return 200 for valid request', async () => {
const response = await fetch('/api/[route-path]');
expect(response.status).toBe(200);
});
test('should return valid JSON response', async () => {
const response = await fetch('/api/[route-path]');
const data = await response.json();
expect(data).toBeDefined();
expect(typeof data).toBe('object');
});
});
describe('POST requests', () => {
test('should create resource with valid data', asyn
Tags
CodeAnalysisaitmplclaude-code-templates