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

@coderic/relay

v2.2.1

Published

Coderic Relay - Real-time messaging infrastructure

Readme

Coderic Relay ⚡

Real-time messaging infrastructure

Coderic Relay es un gateway de comunicación en tiempo real con Socket.io, Redis y Kafka.

Instalación

npm install @coderic/relay

Uso Rápido

Como servidor standalone

# Con npx
npx @coderic/relay

# O con variables de entorno
PORT=5000 REDIS_URL=redis://localhost:6379 npx @coderic/relay

Como librería en tu proyecto

import { createRelay } from '@coderic/relay';

const gateway = createRelay({
  port: 5000,
  redis: { url: 'redis://localhost:6379' },
  kafka: { brokers: ['localhost:9092'] }
});

// Eventos personalizados
gateway.on('connection', (socket) => {
  console.log('Nueva conexión:', socket.id);
});

gateway.on('message', ({ socket, data }) => {
  console.log('Mensaje de', socket.data.usuario, ':', data);
});

await gateway.start();

Cliente Node.js

import { RelayClient } from '@coderic/relay';

const client = new RelayClient('http://localhost:5000');
await client.connect();

// Identificarse
await client.identificar('usuario123');

// Enviar mensajes
client.enviar({ texto: 'Hola mundo!' }, 'nosotros');

// Escuchar mensajes
client.on('mensaje', (data) => {
  console.log('Recibido:', data);
});

Cliente navegador

<script src="https://cdn.socket.io/4.7.5/socket.io.min.js"></script>
<script>
const socket = io('http://localhost:5000/relay');

socket.on('connect', () => {
  socket.emit('identificar', 'miUsuario', (ok) => {
    console.log('Identificado:', ok);
  });
});

// Enviar mensaje a todos
socket.emit('relay', { 
  texto: 'Hola!',
  destino: 'nosotros' 
});

// Recibir mensajes
socket.on('relay', (data) => {
  console.log('Mensaje:', data);
});
</script>

API de Eventos

Eventos del cliente

| Evento | Descripción | Payload | |--------|-------------|---------| | identificar | Identificar usuario | (userId, callback) | | unirse | Unirse a un room (v2.1) | (room, callback) | | notificar | Enviar notificación | { ...data, destino } | | relay | Canal genérico | { ...data, destino } |

Destinos

| Destino | Descripción | |---------|-------------| | yo | Solo al emisor (default) | | ustedes | A todos menos el emisor | | nosotros | A todos incluyendo el emisor | | room | A todos en el room especificado (v2.1) |

Ejemplo con Rooms

// Unirse a un room
socket.emit('unirse', 'aulaA');

// Enviar a ese room
socket.emit('relay', {
  destino: 'room',
  room: 'aulaA',
  tipo: 'mensaje',
  texto: 'Hola aula A'
});

Configuración

Variables de entorno

| Variable | Descripción | Default | |----------|-------------|---------| | PORT | Puerto del servidor | 5000 | | REDIS_URL | URL de Redis | - | | KAFKA_BROKERS | Brokers Kafka (comma-separated) | - | | INSTANCE_ID | ID de instancia | process.pid |

Opciones del constructor

const gateway = createRelay({
  port: 5000,
  instanceId: 'gateway-1',
  namespace: '/relay',
  cors: { origin: '*', methods: ['GET', 'POST'] },
  metrics: true,
  redis: {
    url: 'redis://localhost:6379',
    options: { /* ioredis options */ }
  },
  kafka: {
    brokers: ['localhost:9092'],
    topic: 'relay-events',
    options: { /* kafkajs options */ }
  },
  httpHandler: (req, res) => { /* custom handler */ }
});

Eventos del servidor

gateway.on('ready', ({ port }) => { });
gateway.on('connection', (socket) => { });
gateway.on('disconnect', ({ socket, reason }) => { });
gateway.on('user:identified', ({ usuario, socketId }) => { });
gateway.on('message', ({ socket, data }) => { });
gateway.on('notify', ({ socket, data }) => { });
gateway.on('redis:connected', () => { });
gateway.on('redis:error', (error) => { });
gateway.on('kafka:connected', () => { });
gateway.on('kafka:error', (error) => { });

Endpoints HTTP

| Endpoint | Descripción | |----------|-------------| | /health | Health check (JSON) | | /metrics | Métricas Prometheus |

Docker

docker pull coderic/relay
FROM coderic/relay:latest
ENV PORT=5000
ENV REDIS_URL=redis://redis:6379
ENV KAFKA_BROKERS=kafka:9092
EXPOSE 5000
CMD ["node", "src/server.js"]

Ejemplos

Básicos

💬 Chat en tiempo real

Chat multi-usuario

🍕 Pizza Delivery

Tracking de pedidos

🎫 Booking de Eventos

Reserva de eventos

Reservas y Booking

🚌 Bus Express

Reserva de autobuses (React)

✈️ SkyBooker

Reserva de vuelos (Angular)

🏨 Hotel Booking

Reserva de hoteles (Vue.js)

🎬 Cine

Reserva de asientos de cine (Svelte)

Otros Casos de Uso

💳 PasaPay

Pagos P2P estilo Nequi (Vue.js)

🔨 Subastas

Sistema de subastas en tiempo real (React)

🏦 Cola de Turnos

Sistema de cola tipo banco

Website

🌐 relay.coderic.net

Licencia

MIT © Coderic