npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

api-gateway-cli-tools

v1.0.0

Published

CLI para generar configuraciones y codigo para el API Gateway

Readme

GlobalS1 API Gateway CLI

CLI para generar configuraciones y codigo para el API Gateway de GlobalS1.

Instalacion

# Global
npm install -g globalsone-api-gateway-cli

# O como devDependency
npm install -D globalsone-api-gateway-cli

Uso

# Ver ayuda
apigw --help

# Ver version
apigw --version

Comandos

Generate Middleware

Genera middlewares personalizados para el API Gateway.

# Middleware basico
apigw generate middleware request-logger
apigw g mw request-logger

# Middleware JWT
apigw g mw custom-auth --type jwt

# Middleware Rate Limit con Redis
apigw g mw api-rate-limit --type redis

# Middleware Circuit Breaker
apigw g mw service-protection --type circuit-breaker

# Preview sin crear archivos
apigw g mw my-middleware --dry-run

Opciones:

| Opcion | Descripcion | Default | |--------|-------------|---------| | -t, --type <type> | Tipo de middleware (basic, jwt, redis, circuit-breaker) | basic | | --dry-run | Preview sin crear archivos | false | | --force | Sobrescribir archivos existentes | false |

Generate Upstream

Configura servicios upstream para el proxy.

# Upstream basico
apigw generate upstream user-service --host localhost --port 3001
apigw g up user-service -h localhost -p 3001

# Con paths especificos
apigw g up order-service --port 3002 --paths "/orders,/checkout"

# Con health check
apigw g up payment-service --port 3003 --health "/health/live"

# Con load balancing
apigw g up api-service --instances "api-1:3000,api-2:3000" --strategy round-robin

# Con circuit breaker
apigw g up external-api --port 443 --protocol https --circuit-breaker

# Preview
apigw g up test-service --dry-run

Opciones:

| Opcion | Descripcion | Default | |--------|-------------|---------| | -h, --host <host> | Host del servicio | localhost | | -p, --port <port> | Puerto del servicio | 3001 | | --protocol <protocol> | Protocolo (http, https) | http | | --paths <paths> | Paths manejados (separados por coma) | | | --health <path> | Endpoint de health check | /health | | --timeout <ms> | Timeout en ms | 5000 | | --retries <n> | Numero de reintentos | 3 | | --circuit-breaker | Habilitar circuit breaker | false | | --instances <instances> | Instancias para load balancing | | | --strategy <strategy> | Estrategia de load balancing | round-robin | | --dry-run | Preview sin crear archivos | false | | --force | Sobrescribir configuracion | false |

Generate Route

Configura rutas para el proxy.

# Ruta simple
apigw generate route /api/users --upstream user-service
apigw g r /api/users -u user-service

# Ruta con metodos especificos
apigw g r /api/orders --upstream order-service --methods "GET,POST"

# Ruta con middlewares
apigw g r /api/payments --upstream payment-service --middlewares "auth,rate-limit"

# Ruta con rate limit custom
apigw g r /api/auth/login --upstream auth-service --rate-limit "5/min"

# Ruta con cache
apigw g r /api/products --upstream catalog-service --cache 300

# Preview
apigw g r /api/test --upstream test-service --dry-run

Opciones:

| Opcion | Descripcion | Default | |--------|-------------|---------| | -u, --upstream <name> | Servicio upstream (requerido) | | | -m, --methods <methods> | Metodos HTTP | GET,POST,PUT,DELETE | | --middlewares <list> | Middlewares a aplicar | | | --rate-limit <rate> | Rate limit (ej: 5/min) | | | --timeout <ms> | Timeout especifico | | | --strip-prefix | Eliminar prefijo del path | false | | --cache <ttl> | TTL de cache en segundos | | | --dry-run | Preview sin crear archivos | false | | --force | Sobrescribir configuracion | false |

Generate Validator

Genera validadores de request con AJV.

# Validador basico
apigw generate validator create-user
apigw g v create-user

# Validador con metodo especifico
apigw g v update-order --method PUT

# Preview
apigw g v my-validator --dry-run

Opciones:

| Opcion | Descripcion | Default | |--------|-------------|---------| | -m, --method <method> | Metodo HTTP | POST | | -s, --schema <schema> | Nombre del schema | | | --dry-run | Preview sin crear archivos | false | | --force | Sobrescribir archivos | false |

Generate Health

Genera health checks personalizados.

# Health check basico
apigw generate health basic
apigw g h basic

# Health check con dependencias
apigw g h readiness --deps "redis,database"

# Health check para servicio especifico
apigw g h user-health --service user-service

# Preview
apigw g h custom --dry-run

Opciones:

| Opcion | Descripcion | Default | |--------|-------------|---------| | -d, --deps <deps> | Dependencias a verificar | | | -s, --service <service> | Servicio especifico | | | --dry-run | Preview sin crear archivos | false | | --force | Sobrescribir archivos | false |

Estructura Generada

src/
├── config/
│   ├── upstream-services.json   # Servicios upstream
│   ├── rate-limits.json         # Configuracion rate limiting
│   └── routes.json              # Definicion de rutas
├── middlewares/
│   ├── {name}.middleware.ts     # Middlewares generados
│   └── __tests__/
│       └── {name}.middleware.test.ts
├── validators/
│   ├── {name}.validator.ts      # Validadores generados
│   └── __tests__/
│       └── {name}.validator.test.ts
└── services/
    └── {name}-health.service.ts # Health checks generados

Desarrollo

# Clonar repositorio
git clone https://github.com/GlobalS1/globalsone-api-gateway-cli.git
cd globalsone-api-gateway-cli

# Instalar dependencias
npm install

# Build
npm run build

# Desarrollo (watch mode)
npm run dev

# Link local para testing
npm link

Licencia

MIT