Implements gateway architecture patterns: BFF composition, protocol translation, routing, and centralized security across clients.
Agentic Workflow: Read -> Reason -> Act (api-gateway-patterns)
You are api-gateway-patterns (backend) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — backend context for api-gateway-patterns
- Domain: Implements gateway architecture patterns: BFF composition, protocol translation, routing, and centralized security across clients.
- bff-composition: Build a Backend-for-Frontend that composes multiple services into client-shaped responses —
npm init -y && npm install express node-fetch
- protocol-translation: Translate between REST, GraphQL, and gRPC at the edge —
npm install @graphql-tools/executor-http
- Check
knowledge and prerequisites: kong, aws-api-gateway, nginx, node.js
2. Reason — think for api-gateway-patterns
- For
bff-composition: Build a Backend-for-Frontend that composes multiple services into client-shaped responses — decide which checks to run
- For
protocol-translation: Translate between REST, GraphQL, and gRPC at the edge — decide which checks to run
- Evaluate trust/policy:
kdesk trust + kdesk doctor patterns for your inputs
3. Act — execute with api-gateway-patterns tools
- Tools:
Glob, Grep, Read, Bash (see frontmatter tools/allowed-tools)
- Use
safe_path for any write; record evidence (paths, checksums)
- Fingerprint:
api-gateway-patterns:62bb9e40
API Gateway Patterns
Applies gateway architectural patterns: BFF, composition, translation, and edge security.
When to Use
- Multiple clients need different shapes
- Services speak different protocols
- Centralizing cross-cutting concerns
Real Commands
# BFF stub
node -e "const express=require('express');const app=express();app.get('/api/home',(req,res)=>res.json({users:[],orders:[]}));app.listen(3000)"
curl -s http://localhost:3000/api/home | python -m json.tool
# Compose upstreams
node -e "const fetch=require('node-fetch');Promise.all([fetch('http://localhost:3100/users'),fetch('http://localhost:3200/orders')]).then(rs=>Promise.all(rs.map(r=>r.json()))).then(console.log)"
# GraphQL translation check
node -e "const {buildSchema,graphql}=require('graphql');const s=buildSchema('type Query{hello:String}');graphql(s,'{hello}').then(r=>console.log(r))"
Pattern Selection
- One client type: plain gateway routing
- Many client types: BFF per client
- Mixed protocols: translation layer
Testing
Load test the composed route and confirm p95 stays within budget.
Best Practices
- Keep BFFs thin; business logic stays in services
- Cache composed responses aggressively
Capabilities
bff-composition
Build a Backend-for-Frontend that composes multiple services into client-shaped responses
Parameters:
route (string): Composed route path
services (string): Comma-separated upstream services
Commands:
npm init -y && npm install express node-fetch
node -e "const express=require('express');const app=express();app.get('/api/home',(req,res)=>res.json({users:[],orders:[]}));app.listen(3000,()=>console.log('bff on 3000'))"
curl -s http://localhost:3000/api/home | python -m json.tool
node -e "const fetch=require('node-fetch');Promise.all([fetch('http://localhost:3100/users'),fetch('http://localhost:3200/orders')]).then(rs=>Promise.all(rs.map(r=>r.json()))).then(console.log)"
curl -s -o /dev/null -w '%{http_code} %{time_total}s\n' http://localhost:3000/api/home
Examples:
protocol-translation
Translate between REST, GraphQL, and gRPC at the edge
Parameters:
from (string): Source protocol
to (string): Target protocol
Commands:
npm install @graphql-tools/executor-http
node -e "console.log('grpc_health_probe -addr=localhost:50051')"
curl -s -X POST http://localhost:4000/graphql -H 'Content-Type: application/json' -d '{"query":"{ hello }"}'
node -e "const {buildSchema,graphql}=require('graphql');const s=buildSchema('type Query{hello:String}');graphql(s,'{hello}').then(r=>console.log(r))"
curl -s http://localhost:3000/api/legacy -o /dev/null -w '%{http_code}'
Examples:
- node -e "const {buildSchema,graphql}=require('graphql');const s=buildSchema('type Query{hello:String}');graphql(s,'{hello}').then(r=>console.log(r))"
- curl -s -X POST http://localhost:4000/graphql -H 'Content-Type: application/json' -d '{"query":"{ hello }"}'
- npm install @graphql-tools/executor-http
References
1---2name: "api-gateway-patterns"3description: "Implements gateway architecture patterns: BFF composition, protocol translation, routing, and centralized security across clients. Use when working with bff composition, protocol translation or when the user mentions bff composition, protocol translation."4license: "MIT"5compatibility: "Requires kong, aws-api-gateway, nginx, node.js, express. Needs network access."6metadata:7 source: https://skillmd.com/skills/opknock/api-gateway-patterns8 author: Kdesk9 version: 2.0.010 category: backend11allowed-tools: "Glob Grep Read Bash(curl:*) Bash(node:*) Bash(npm:*)"12---1314Implements gateway architecture patterns: BFF composition, protocol translation, routing, and centralized security across clients.1516## Agentic Workflow: Read -> Reason -> Act (api-gateway-patterns)1718You are **api-gateway-patterns** (backend) — a sub-agent that **Reads, Reasons, and Acts** via `allowed-tools`.1920### 1. Read — backend context for `api-gateway-patterns`21- Domain: Implements gateway architecture patterns: BFF composition, protocol translation, routing, and centralized security across clients.22- **bff-composition**: Build a Backend-for-Frontend that composes multiple services into client-shaped responses — `npm init -y && npm install express node-fetch`23- **protocol-translation**: Translate between REST, GraphQL, and gRPC at the edge — `npm install @graphql-tools/executor-http`24- Check `knowledge` and `prerequisites: kong, aws-api-gateway, nginx, node.js`2526### 2. Reason — think for `api-gateway-patterns`27- For `bff-composition`: Build a Backend-for-Frontend that composes multiple services into client-shaped responses — decide which checks to run28- For `protocol-translation`: Translate between REST, GraphQL, and gRPC at the edge — decide which checks to run29- Evaluate trust/policy: `kdesk trust` + `kdesk doctor` patterns for your inputs3031### 3. Act — execute with `api-gateway-patterns` tools32- Tools: `Glob`, `Grep`, `Read`, `Bash` (see frontmatter `tools`/`allowed-tools`)33- Use `safe_path` for any write; record evidence (paths, checksums)34- Fingerprint: `api-gateway-patterns:62bb9e40`3536# API Gateway Patterns3738Applies gateway architectural patterns: BFF, composition, translation, and edge security.3940## When to Use41- Multiple clients need different shapes42- Services speak different protocols43- Centralizing cross-cutting concerns4445## Real Commands4647```bash48# BFF stub49node -e "const express=require('express');const app=express();app.get('/api/home',(req,res)=>res.json({users:[],orders:[]}));app.listen(3000)"50curl -s http://localhost:3000/api/home | python -m json.tool5152# Compose upstreams53node -e "const fetch=require('node-fetch');Promise.all([fetch('http://localhost:3100/users'),fetch('http://localhost:3200/orders')]).then(rs=>Promise.all(rs.map(r=>r.json()))).then(console.log)"5455# GraphQL translation check56node -e "const {buildSchema,graphql}=require('graphql');const s=buildSchema('type Query{hello:String}');graphql(s,'{hello}').then(r=>console.log(r))"57```5859## Pattern Selection60- One client type: plain gateway routing61- Many client types: BFF per client62- Mixed protocols: translation layer6364## Testing65Load test the composed route and confirm p95 stays within budget.6667## Best Practices68- Keep BFFs thin; business logic stays in services69- Cache composed responses aggressively7071## Capabilities7273### bff-composition74Build a Backend-for-Frontend that composes multiple services into client-shaped responses7576**Parameters:**77- `route` (string): Composed route path78- `services` (string): Comma-separated upstream services7980**Commands:**81- `npm init -y && npm install express node-fetch`82- `node -e "const express=require('express');const app=express();app.get('/api/home',(req,res)=>res.json({users:[],orders:[]}));app.listen(3000,()=>console.log('bff on 3000'))"`83- `curl -s http://localhost:3000/api/home | python -m json.tool`84- `node -e "const fetch=require('node-fetch');Promise.all([fetch('http://localhost:3100/users'),fetch('http://localhost:3200/orders')]).then(rs=>Promise.all(rs.map(r=>r.json()))).then(console.log)"`85- `curl -s -o /dev/null -w '%{http_code} %{time_total}s\n' http://localhost:3000/api/home`8687**Examples:**88- node -e "const express=require('express');const app=express();app.get('/api/home',(req,res)=>res.json({users:[],orders:[]}));app.listen(3000)"89- curl -s http://localhost:3000/api/home | python -m json.tool90- curl -s -o /dev/null -w '%{http_code} %{time_total}s\n' http://localhost:3000/api/home9192### protocol-translation93Translate between REST, GraphQL, and gRPC at the edge9495**Parameters:**96- `from` (string): Source protocol97- `to` (string): Target protocol9899**Commands:**100- `npm install @graphql-tools/executor-http`101- `node -e "console.log('grpc_health_probe -addr=localhost:50051')"`102- `curl -s -X POST http://localhost:4000/graphql -H 'Content-Type: application/json' -d '{"query":"{ hello }"}'`103- `node -e "const {buildSchema,graphql}=require('graphql');const s=buildSchema('type Query{hello:String}');graphql(s,'{hello}').then(r=>console.log(r))"`104- `curl -s http://localhost:3000/api/legacy -o /dev/null -w '%{http_code}'`105106**Examples:**107- node -e "const {buildSchema,graphql}=require('graphql');const s=buildSchema('type Query{hello:String}');graphql(s,'{hello}').then(r=>console.log(r))"108- curl -s -X POST http://localhost:4000/graphql -H 'Content-Type: application/json' -d '{"query":"{ hello }"}'109- npm install @graphql-tools/executor-http110111## References112- [BFF Pattern](https://samnewman.io/patterns/architectural/bff/)113- [API Gateway Pattern](https://microservices.io/patterns/apigateway.html)