backend-patterns

Implements backend architecture patterns for Node.js, Express, and Next.js API routes.

Updated Mar 26, 2026
One-click install
npx skills add https://github.com/erwinv2k-TKG/AgentesVSC --skill backend-patterns-erwinv2k-tkg
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: backend-patterns
Source: https://github.com/erwinv2k-TKG/AgentesVSC/tree/main/packs/everything-claude-code/docs/zh-TW/skills/backend-patterns
Command: npx skills add https://github.com/erwinv2k-TKG/AgentesVSC --skill backend-patterns-erwinv2k-tkg

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building scalable server-side applications requires consistent patterns for API design, database access, caching, authentication, and error handling, and this Skill provides ready-to-use reference implementations in TypeScript. ## Core Features & Use Cases - API & Layering Patterns: RESTful route design, Repository pattern, Service layer separation, and middleware pipelines for Next.js API routes. - Data & Performance Patterns: Supabase query optimization, N+1 query prevention, transaction handling, Redis cache-aside strategies, and rate limiting. - Security & Reliability: JWT verification, role-based access control, centralized error handling, exponential backoff retries, background job queues, and structured logging. - Use Case: When building a Next.js API that queries Supabase, apply the Repository pattern with Redis caching and JWT auth middleware to get a maintainable, performant endpoint without designing the architecture from scratch. ## Quick Start Ask the assistant to apply the backend patterns skill to design a cached, authenticated Next.js API route backed by Supabase.

Frequently Asked Questions about backend-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a RESTful API in Next.js?

Use resource-based URLs like GET /api/markets/:id for single resources and query parameters for filtering, sorting, and pagination. Wrap handlers with middleware functions for authentication and centralize error handling in a shared errorHandler function.

How to prevent N+1 query problems with Supabase?

Batch fetch related records instead of querying in a loop. Collect all foreign keys, run one query to fetch the related rows, then build a Map keyed by ID to join the results in memory.

What is the Repository pattern in TypeScript backend development?

The Repository pattern abstracts data access behind an interface like MarketRepository with methods such as findAll and findById. Concrete implementations like SupabaseMarketRepository handle the actual queries, keeping business logic independent of the database.

Does the cache-aside pattern work with Redis and Next.js API routes?

Yes, check Redis for a cached key first, and on a miss query the database and store the result with setex and a TTL such as 300 seconds. Invalidate the key with redis.del when the underlying record changes.

How do I implement role-based access control in an API?

Map roles like admin, moderator, and user to permission arrays, then use a higher-order requirePermission function that verifies the JWT, checks the permission, and only then invokes the handler. Unauthorized requests return 403 responses.

When should I use a background job queue instead of handling work in the request?

Use an in-memory job queue for non-blocking tasks like indexing after a resource is created, so the API responds immediately. For distributed or persistent workloads, a simple in-process queue is not sufficient and a dedicated queue system is needed.