api-version
БесплатноБез исполняемых скриптовНе проверенManage API versioning strategy for Hono routes in apps/api/src/v1. Use when creating new API versions or migrating endpoints between versions.
от diegosouzapw★ 68 звёзд на GitHubОб этом скилле
API Versioning Skill
This skill helps you manage API versions in apps/api/src/v1/ and prepare for future versions.
When to Use This Skill
- Creating a new API version (v2, v3, etc.)
- Deprecating old API endpoints
- Migrating endpoints between versions
- Planning breaking changes
- Maintaining backward compatibility
Current API Structure
apps/api/src/
├── v1/ # Current API version
│ ├── routes/
│ │ ├── cars.ts # Car registration endpoints
│ │ ├── coe.ts # COE bidding endpoints
│ │ ├── pqp.ts # PQP data endpoints
│ │ └── health.ts # Health check
│ └── index.ts # v1 router assembly
└── index.ts # Main Hono app with versioned routes
Versioning Strategy
URL-Based Versioning
The project uses URL path versioning:
https://api.sgcarstrends.com/v1/carshttps://api.sgcarstrends.com/v1/coe- Future:
https://api.sgcarstrends.com/v2/cars
Benefits
- Clear, explicit versioning visible in URLs
- Easy to cache and monitor per version
- Clients can migrate at their own pace
- Multiple versions can coexist
Creating a New API Version
Step 1: Create Version Directory
mkdir -p apps/api/src/v2/routes
Step 2: Copy Existing Routes
Start with current v1 routes as a base:
cp -r apps/api/src/v1/routes/* apps/api/src/v2/routes/
Step 3: Create Version Router
Create apps/api/src/v2/index.ts:
import { Hono } from "hono";
import { carsRouter } from "./routes/cars";
import { coeRouter } from "./routes/coe";
import { pqpRouter } from "./routes/pqp";
const v2 = new Hono();
// Mount routes
v2.route("/cars", carsRouter);
v2.route("/coe", coeRouter);
v2.route("/pqp", pqpRouter);
export default v2;
Step 4: Mount in Main App
Update apps/api/src/index.ts:
import { Hono } from "hono";
import v1 from "./v1";
import v2 from "./v2";
const app = new Hono();
// Mount API versions
app.route("/v1", v1);
app.route("/v2", v2); // Add new version
// Default to latest stable version
app.route("/", v1); // Keep v1 as default or change to v2 when stable
export default app;
Step 5: Implement Breaking Changes
Make necessary changes in v2 routes:
// v1 response format
{
"success": true,
"data": [...],
"count": 10
}
// v2 response format (breaking change)
{
"data": [...],
"meta": {
"total": 10,
"page": 1,
"pageSize": 10
}
}
Migration Patterns
1. Gradual Migration
Keep both versions running:
// v1/routes/cars.ts - deprecated but maintained
export const carsRouter = new Hono();
carsRouter.get("/", async (c) => {
// Old logic
return c.json({
success: true,
data: await getCars(),
});
});
// v2/routes/cars.ts - new implementation
export const carsRouter = new Hono();
carsRouter.get("/", async (c) => {
// New logic with pagination
const { page = 1, limit = 10 } = c.req.query();
const result = await getCars({ page, limit });
return c.json({
data: result.items,
meta: {
total: result.total,
page,
pageSize: limit,
},
});
});
2. Feature Flag Pattern
Use feature flags to test changes:
import { Hono } from "hono";
export const carsRouter = new Hono();
carsRouter.get("/", async (c) => {
const useV2Format = c.req.header("X-API-Version") === "2";
const data = await getCars();
if (useV2Format) {
return c.json({ data, meta: { ... } });
}
// v1 format
return c.json({ success: true, data });
});
3. Deprecation Warnings
Add deprecation headers to v1:
import { Hono } from "hono";
export const carsRouter = new Hono();
// Add deprecation middleware
carsRouter.use("*", async (c, next) => {
await next();
c.header("X-API-Deprecation", "true");
c.header("X-API-Sunset", "2025-12-31");
c.header("Link", '<https://api.sgcarstrends.com/v2/cars>; rel="successor-version"');
});
carsRouter.get("/", async (c) => {
// Existing logic
});
Breaking Changes Checklist
When introducing breaking changes, consider:
- Response structure changes
- Required parameter additions
- Authentication method changes
- URL structure modifications
- HTTP method changes
- Header requirement changes
- Error format modifications
- Data type changes
Version Documentation
Document versions in OpenAPI/Swagger:
// apps/api/src/v2/openapi.ts
import { OpenAPIHono } from "@hono/zod-openapi";
const app = new OpenAPIHono();
app.openapi(
{
method: "get",
path: "/cars",
summary: "Get car registrations (v2)",
deprecated: false,
tags: ["Cars"],
responses: {
200: {
description: "Success",
content: {
"application/json": {
schema: carResponseSchema,
},
},
},
},
},
async (c) => {
// Handler
}
);
Version Sunset Process
1. Ann
Установить api-version в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadEditWriteGrepGlobВложенные файлы
FAQ
Что делает скилл api-version?
Manage API versioning strategy for Hono routes in apps/api/src/v1. Use when creating new API versions or migrating endpoints between versions.
Как установить скилл api-version?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл api-version запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic