Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API Gateway Example with Node.js

Ejemplo simple de arquitectura con API Gateway y microservicios utilizando Node.js, Express y http-proxy-middleware.


Descripción

Este ejemplo demuestra cómo un API Gateway puede actuar como punto de entrada único para múltiples microservicios.


Arquitectura

Cliente
   ↓
API Gateway (3000)
   ↓
 ┌───────────────┬───────────────┐
 ↓                               ↓
Products Service          Orders Service
(3001)                    (3002)

Instalación

1. Clonar el repositorio

git clone <URL_DEL_REPOSITORIO>
cd api_gateway_example

2. Instalar dependencias

npm install

Cómo ejecutar el proyecto

Abrir 3 terminales diferentes.

Terminal 1 — Products Service

node products-service.js

Terminal 2 — Orders Service

node orders-service.js

Terminal 3 — API Gateway

node gateway.js

Autenticación

El API Gateway valida un token simple mediante el header:

Authorization: mitoken

Pruebas

1. Obtener productos

curl -H "Authorization: mitoken" http://localhost:3000/productos

2. Ver órdenes

curl -H "Authorization: mitoken" http://localhost:3000/ordenes

3. Crear orden

curl -X POST http://localhost:3000/ordenes \
-H "Authorization: mitoken" \
-H "Content-Type: application/json" \
-d '{"usuario":"Laura","producto":"Camisa"}'

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages