.internal-skills/api-gateway-specialist/SKILL.md
Especialista em API Gateway e Gestão de APIs. Use para: - Configurar API Gateway - Rate limiting e throttling - Load balancing - Service discovery - GraphQL federation - API versioning e lifecycle
npx skillsauth add suportebahia/equipe-devs Equipe SBahia - API Gateway SpecialistInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
# kong.yml - Declarative config
_format_version: "3.0"
services:
- name: user-service
url: http://user-service:3000
routes:
- name: user-routes
paths:
- /api/v1/users
strip_path: true
plugins:
- name: rate-limiting
config:
minute: 100
hour: 1000
policy: local
- name: cors
config:
origins:
- "https://app.example.com"
methods:
- GET
- POST
- PUT
- DELETE
headers:
- Authorization
- Content-Type
- name: jwt
config:
key_claim_name: kid
- name: order-service
url: http://order-service:3001
routes:
- name: order-routes
paths:
- /api/v1/orders
plugins:
- name: oauth2
config:
scopes:
- read
- write
mandatory_scope: true
# OpenAPI spec com.extensions
openapi: 3.0.0
x-amazon-apigateway-integration:
uri: arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/${MyFunction.Arn}/invocations
httpMethod: POST
type: aws_proxy
x-amazon-apigateway-throttling:
burstLimit: 100
rateLimit: 50
x-amazon-apigateway-cache-key-parameters:
- query.userId
// Token Bucket Algorithm
class TokenBucket {
constructor(capacity, refillRate) {
this.capacity = capacity;
this.tokens = capacity;
this.refillRate = refillRate; // tokens por segundo
this.lastRefill = Date.now();
}
consume(tokens = 1) {
this.refill();
if (this.tokens >= tokens) {
this.tokens -= tokens;
return true;
}
return false;
}
refill() {
const now = Date.now();
const elapsed = (now - this.lastRefill) / 1000;
this.tokens = Math.min(
this.capacity,
this.tokens + elapsed * this.refillRate
);
this.lastRefill = now;
}
}
// Usage per client
const clientBuckets = new Map();
function rateLimitMiddleware(req, res, next) {
const clientId = req.apiKey || req.ip;
if (!clientBuckets.has(clientId)) {
clientBuckets.set(clientId, new TokenBucket(100, 1.66));
}
const bucket = clientBuckets.get(clientId);
if (!bucket.consume()) {
return res.status(429).json({
error: 'Too Many Requests',
retryAfter: Math.ceil((bucket.capacity - bucket.tokens) / bucket.refillRate)
});
}
next();
}
// Apollo Federation
@Resolver('User')
export class UserResolver {
@Query(() => User)
async user(@Args() { id }: { id: string }): Promise<User> {
return this.userService.findById(id);
}
@FieldResolver(() => [Order])
async orders(@Root() user: User): Promise<Order[]> {
return this.orderService.findByUserId(user.id);
}
}
// Schema federation
extend type User @key(fields: "id") {
id: ID! @external
orders: [Order]
}
# Kong plugin - request-termination
services:
- name: fragile-service
plugins:
- name: request-termination
config:
status_code: 503
message: Service temporarily unavailable
rate_limit_ip: 10
period: 1
# Or proxy-cache with expired behavior
plugins:
- name: proxy-cache
config:
response_code:
- 200
request_method:
- GET
cache_ttl: 30
/api/v1/users ← Ativo (manutenção)
/api/v2/users ← Ativo (principal)
/api/v3/users ← Beta (novos clientes)
/api/beta/users ← Experimental
{
"deprecation": {
"sunsetDate": "2024-06-01",
"noticeDate": "2024-03-01",
"migrationGuide": "/docs/v2-to-v3-migration",
"alternative": "v3",
"status": "deprecated"
}
}
// Version negotiation
app.use((req, res, next) => {
const version = req.headers['Accept-Version'] || 'v1';
if (version === 'v1' && Date.now() > '2024-06-01') {
res.set('Sunset', 'Sat, 01 Jun 2024 00:00:00 GMT');
res.set('Deprecation', 'true');
}
req.apiVersion = version;
next();
});
// Redis cache with invalidation
const cacheKey = `user:${userId}`;
async function getUser(id) {
const cached = await redis.get(cacheKey);
if (cached) return JSON.parse(cached);
const user = await db.users.findById(id);
await redis.setex(cacheKey, 300, JSON.stringify(user));
return user;
}
async function updateUser(id, data) {
const user = await db.users.update(id, data);
await redis.del(`user:${id}`); // Invalidate
return user;
}
// Pattern: Cache-aside (lazy loading)
# CloudFront behavior
Origins:
- Domain: api.example.com
OriginPath: /v1
Behaviors:
- PathPattern: /static/*
ViewerProtocolPolicy: redirect-to-https
CachePolicyId: 4135ea2d-6df8-44a3-9df3-4b5a84be39ad
- PathPattern: /api/*
ViewerProtocolPolicy: https-only
CachePolicyId: 4135ea2d-6df8-44a3-9df3-4b5a84be39ad
| Métrica | Descrição | Alerta | |---------|-----------|--------| | Latência P99 | 99% das requisições | > 2s | | Error Rate | % de 5xx | > 1% | | Throughput | req/s | < baseline | | Saturation | uso de conexão | > 80% |
| Tipo | Ferramenta | |------|------------| | API Gateway | Kong, AWS API Gateway, NGINX, Traefik | | Load Balancer | HAProxy, AWS ALB, CloudFlare | | Cache | Redis, Memcached, Varnish | | CDN | CloudFront, CloudFlare, Fastly | | Monitoring | Datadog, Prometheus, New Relic | | API Docs | Swagger, Redoc, Postman |
testing
Sistema de agentes IA para coordenação de projetos de desenvolvimento. Use este skill para iniciar qualquer projeto. Este skill orquestra automaticamente os agentes especializados conforme a necessidade: - Análise e planejamento de projetos - Coordenação de múltiplos agentes - Gestão de tasks e dependências
development
Orquestrador principal do ecossistema de agentes IA Equipe SBahia. Use para: - Coordenar projetos de desenvolvimento web - Alocar agentes especializados - Gerenciar workflow completo - Garantir padrões MVC e de mercado Agents disponíveis: leadership-tech, uxui-designer, frontend-developer, backend-controller, backend-model, dba-specialist, security-specialist, api-gateway-specialist, mobile-developer, data-engineer, elastic-engineer, machine-learning-engineer, testing-specialist, error-handling-specialist, product-owner, devops-engineer, solutions-engineer
testing
Skill para Designer UX/UI. Use para: - Criar experiência do usuário - Desenvolver interfaces visuais - Definir design system - Validar usabilidade
testing
Especialista em QA/Testes automatizados. Use para: - Criar estratégia de testes completa - Implementar testes unitários, integração e E2E - TDD/BDD quando aplicável - Coverage analysis - Testes de performance e carga