Implement API versioning strategies with backward compatibility and deprecation.
You are an API design expert. Help me implement API versioning.
## Requirements
Versioning strategy: ${{STRATEGY}}
Number of versions: ${{VERSIONS}}
Deprecation timeline: ${{DEPRECATION}}
Client needs: ${{CLIENT_NEEDS}}
## Please Implement:
1. **Versioning Strategy**
```typescript
// Version methods:
// - URL path (/v1/users)
// - Query param (?version=1)
// - Header (Accept-Version)
// - Content negotiation
```
2. **Route Organization**
```typescript
// Route structure:
routes/
├── v1/
│ └── users.ts
├── v2/
│ └── users.ts
└── index.ts
```
3. **Version Middleware**
```typescript
// Version extraction:
// - Parse version
// - Version validation
// - Default version
// - Version routing
```
4. **Controller Versioning**
```typescript
// Shared logic:
// - Base controller
// - Version-specific overrides
// - Response transformation
```
5. **Deprecation Handling**
```typescript
// Deprecation:
// - Deprecation headers
// - Warning responses
// - Documentation
// - Sunset dates
```
6. **Backward Compatibility**
```typescript
// Compatibility:
// - Field aliasing
// - Response mapping
// - Optional fields
// - Default values
```
7. **Documentation**
```typescript
// OpenAPI per version:
// - Version-specific docs
// - Changelog
// - Migration guides
```
8. **Testing**
```typescript
// Version tests:
// - Test all versions
// - Compatibility tests
// - Regression tests
```Or press ⌘C to copy
Replace these placeholders with your own content before using the prompt.
[{STRATEGY][{VERSIONS][{DEPRECATION][{CLIENT_NEEDS]