api-patterns

Solid

API design, versioning, testing, schema validation, and contract testing patterns for REST and GraphQL APIs.

API & Backend 496 stars 41 forks Updated 1 months ago MIT

Install

View on GitHub

Quality Score: 86/100

Stars 20%
90
Recency 20%
75
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# API Patterns REST and GraphQL API design patterns for consistent, versioned, and well-tested interfaces. ## API Versioning ### URL-Based Versioning ```typescript // routes/v1/markets.ts // routes/v2/markets.ts // URL: /api/v1/markets, /api/v2/markets // Express router setup import { Router } from 'express' const v1Router = Router() const v2Router = Router() app.use('/api/v1', v1Router) app.use('/api/v2', v2Router) // Deprecation header middleware function deprecationWarning(version: string, sunsetDate: string) { return (_req: Request, res: Response, next: NextFunction) => { res.setHeader('Deprecation', 'true') res.setHeader('Sunset', sunsetDate) res.setHeader('Link', `</api/v${parseInt(version) + 1}>; rel="successor-version"`) next() } } v1Router.use(deprecationWarning('1', 'Sat, 01 Jan 2027 00:00:00 GMT')) ``` ### Header-Based Versioning ```typescript // Accept: application/vnd.api+json;version=2 function versionMiddleware(req: Request, res: Response, next: NextFunction) { const accept = req.headers['accept'] || '' const match = accept.match(/version=(\d+)/) req.apiVersion = match ? parseInt(match[1]) : 1 next() } ``` ## Schema Validation with Zod ### Request + Response Validation ```typescript import { z } from 'zod' // Request schema const CreateMarketSchema = z.object({ name: z.string().min(1).max(200), description: z.string().max(2000).optional(), category: z.enum(['sports', 'politics', 'crypto', 'tech']), closeAt: z.s...

Details

Author
vibeeval
Repository
vibeeval/vibecosystem
Created
2 months ago
Last Updated
1 months ago
Language
C#
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category