Bỏ qua tới nội dung
TakoAPI
Quay lại kỹ năng

backend-patterns

bởi charmmm718

Coding Agents & IDEs
4.9kLượt tải do clawskills.sh công bố
4Sao
0Lượt xem
0 lượt thíchĐăng nhập để thích kỹ năng này
—Chưa có đánh giá
Đánh giá của bạn

Tóm tắt

Backend architecture patterns, API design, database.

Mô tả

Kỹ năng này làm gì

Backend architecture patterns for Node.js and Next.js API routes. Covers RESTful API design, repository and service layers, database query optimization, Redis caching, JWT authentication, rate limiting, and structured logging, all with TypeScript examples.

Provides ready-to-copy TypeScript patterns for the most common backend concerns so you spend time on business logic instead of re-architecting auth, caching, and error handling each project.

Khi nào nên dùng

  • Adding JWT auth middleware to a Next.js API route
  • Fixing N+1 query problems in a data-heavy endpoint
  • Caching frequent database reads with Redis
  • Setting up role-based access control for admin-only routes
  • Implementing rate limiting on a public API endpoint

Quy trình ví dụ

ĐẦU VÀO

User asks: How do I protect my Next.js DELETE route so only admins can use it?

AGENT
  1. 1

    Identify the role-based access control pattern from the skill

  2. 2

    Define a rolePermissions map assigning read, write, delete, and admin permissions per role

  3. 3

    Implement a requirePermission higher-order function that wraps route handlers

  4. 4

    Call requireAuth inside requirePermission to verify the JWT and extract the user

  5. 5

    Wrap the DELETE handler with requirePermission('delete')

ĐẦU RA

A typed DELETE route handler that returns 401 for missing tokens, 403 for insufficient role, and 200 only for users with the delete permission

Cài đặt

clawhub install charmmm718/backend-patterns

Chạy lệnh CLI, hoặc dán prompt vào Claude Code, Cursor, Codex hay coding agent bạn đang dùng.

Liên kết