Next.js API Endpoint Generator

VerifiedSafe

Creates Next.js API routes using Prisma and Neon PostgreSQL, including CRUD endpoints for products, sales, expenses, and stock movements. Includes JWT authentication and handles offline sync payloads.

Sby Skills Guide Bot
DevelopmentIntermediate
806/2/2026
Claude Code
#nextjs#api-routes#prisma#neon-postgresql#jwt-auth

Recommended for

Our review

Generates Next.js API routes with Prisma and Neon PostgreSQL for the Seri application, including JWT authentication and offline sync handling.

Strengths

  • Automates CRUD API route creation with Prisma
  • Integrates JWT authentication to secure endpoints
  • Handles offline sync payloads
  • Uses Neon PostgreSQL for a scalable database

Limitations

  • Specific to the Seri app, requires adaptation for other projects
  • Does not handle updating or deleting existing routes
  • Assumes Prisma and Neon are already configured
When to use it

When you need to quickly create REST API endpoints for a Next.js application using Prisma and Neon.

When not to use it

For projects not using Next.js, Prisma, or Neon, or when JWT authentication is not required.

Security analysis

Safe
Quality score75/100

The skill provides code templates for Next.js API routes with JWT authentication and Prisma. There are no destructive commands, exfiltration attempts, or obfuscated payloads. The code follows standard practices and relies on environment variables for secrets.

No concerns found

Examples

Create API resource routes
Create a new API resource for products with CRUD endpoints using Prisma and JWT auth.
Add sync endpoint
Add a sync endpoint for offline queue payloads with authentication.
Create auth login route
Create a login endpoint that verifies PIN and returns a JWT token.

/seri-api - API Endpoint Generator

Generate Next.js API routes with Neon PostgreSQL and Prisma for Seri.

Instructions

  1. Create Next.js Route Handlers in src/app/api/
  2. Use Prisma with Neon adapter for database operations
  3. Add JWT authentication middleware
  4. Handle sync payloads from offline queue
  5. Return proper JSON responses

API Route Template

// src/app/api/{resource}/route.ts
import { NextRequest, NextResponse } from 'next/server';
import { prisma } from '@/lib/prisma';
import { verifyAuth } from '@/lib/auth';

export async function GET(request: NextRequest) {
  const user = await verifyAuth(request);
  if (!user) {
    return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
  }

  const data = await prisma.resource.findMany();
  return NextResponse.json(data);
}

export async function POST(request: NextRequest) {
  const user = await verifyAuth(request);
  if (!user) {
    return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
  }

  const body = await request.json();
  const result = await prisma.resource.create({ data: body });
  return NextResponse.json(result, { status: 201 });
}

Auth Helper

// src/lib/auth.ts
import { NextRequest } from 'next/server';
import { jwtVerify } from 'jose';

export async function verifyAuth(request: NextRequest) {
  const token = request.headers.get('authorization')?.replace('Bearer ', '');
  if (!token) return null;

  try {
    const secret = new TextEncoder().encode(process.env.JWT_SECRET);
    const { payload } = await jwtVerify(token, secret);
    return payload;
  } catch {
    return null;
  }
}

Endpoints to Create

  • POST /api/auth/login - Verify PIN, return JWT
  • POST /api/sync - Handle sync queue items
  • GET/POST /api/products - Product CRUD
  • GET/POST /api/sales - Sales
  • GET/POST /api/expenses - Expenses (OWNER only)
  • GET/POST /api/stock-movements - Stock adjustments
Related skills