Create Next.js API routes for the CarbonLens public API:
- POST /api/v1/calculate/transport.accepts transport parameters, returns emissions
- POST /api/v1/calculate/energy.accepts energy usage (kWh, fuel type), returns emissions
- POST /api/v1/calculate/diet.accepts meal description or diet type, returns daily/annual emissions
- GET /api/v1/factors.returns all emission factors with sources
Requirements:
- API key authentication via x-api-key header
- Rate limiting: 100 requests/hour for free tier
- Consistent error response format: { error: string, code: string }
- OpenAPI/Swagger documentation comments
- Input validation with zod on all endpoints
Store API keys and usage counts in the database.