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 🙏

© 2025 – Pkg Stats / Ryan Hefner

apieye

v1.0.0

Published

Advanced Logging and Monitoring middleware for Express with built-in Dashboard

Downloads

89

Readme

APIEye 👁️

APIEye es un middleware de monitoreo y logging "Plug & Play" para aplicaciones Express.js. Captura, almacena y visualiza el tráfico de tu API en tiempo real sin depender de servicios externos de terceros.

Version License TypeScript

🚀 Características Principales

  • 📊 Dashboard Visual Integrado: Interfaz web completa (SPA) para ver métricas, gráficos de tráfico y tasas de error en tiempo real.
  • 🔌 Zero Config: Funciona inmediatamente después de instalar usando SQLite local.
  • 🔍 Inspector de Tráfico: Examina a fondo cada petición: Headers, Query Params, Body (Request/Response) y Latencia.
  • 🛡️ Privacidad Primero: Sistema de sanitización automático para ocultar credenciales, tokens y datos sensibles en los logs.
  • 💾 Persistencia Flexible: Soporte nativo para SQLite (con modo WAL de alto rendimiento) y arquitectura preparada para PostgreSQL.
  • ⚡ Rendimiento: Operaciones de escritura asíncronas para no bloquear el Event Loop de tu API.

📦 Instalación

Instala el paquete en tu proyecto de Node.js:

npm install apieye

Nota: APIEye requiere express versión 4.17.0 o superior.


🛠️ Uso Rápido

Integra APIEye en tu servidor Express en menos de 2 minutos.

import express from 'express';
import { expressMiddleware, createMonitoringRouter } from 'apieye';

const app = express();
const PORT = 3000;

// 1. IMPORTANTE: Parsea el JSON antes para poder capturar el body
app.use(express.json());

// 2. Activa el Middleware de Logging (Captura todo el tráfico)
app.use(expressMiddleware);

// 3. Define tus rutas normales
app.get('/api/hello', (req, res) => {
  res.json({ message: 'Hola mundo desde APIEye!' });
});

// 4. Activa el Dashboard Visual (Opcional pero recomendado)
// Accede a: http://localhost:3000/api/monitoring
app.use('/api/monitoring', createMonitoringRouter());

app.listen(PORT, () => {
  console.log(`Server running on http://localhost:${PORT}`);
  console.log(`📊 Dashboard en http://localhost:${PORT}/api/monitoring`);
});

⚙️ Configuración

APIEye funciona "out-of-the-box" con valores por defecto seguros. Para personalizarlo, crea un archivo llamado logger.config.json en la raíz de tu proyecto (junto a tu package.json).

Ejemplo de logger.config.json:

{
  "storage": {
    "strategy": "sqlite",
    "sqlite": {
      "database_path": "./logs/traffic.db"
    }
  },
  "capture": {
    "request_body": true,
    "response_body": true,
    "request_headers": true,
    "sensitive_headers": ["authorization", "password", "token", "x-api-key"]
  },
  "monitoring": {
    "enabled": true,
    "endpoint": "/api/monitoring"
  }
}

Opciones Disponibles

| Sección | Opción | Descripción | Default | |---------|--------|-------------|---------| | storage | strategy | Motor de base de datos (memory, sqlite) | memory | | | sqlite.database_path | Ruta donde se guardará el archivo .db | ./logs.db | | capture | request_body | Capturar el cuerpo de las peticiones POST/PUT | true | | | response_body | Capturar el cuerpo de la respuesta enviada | false | | | sensitive_headers | Lista de headers/campos JSON a ocultar (REDACTED) | ['auth', ...] | | monitoring| enabled | Activar o desactivar las rutas del dashboard | true |


🖥️ El Dashboard

APIEye incluye una interfaz gráfica embebida. No necesitas instalar nada extra.

  • Vista General: Tarjetas con KPIs (Requests por minuto, Latencia P95, Errores 5xx).
  • Gráficos: Distribución por Métodos HTTP y Códigos de Estado.
  • Explorador: Tabla paginada con filtros avanzados (por fecha, método, búsqueda de texto).
  • Detalle: Vista "Developer Tools" con JSON formateado y coloreado.

Para acceder, simplemente navega a la ruta configurada (ej. /api/monitoring) en tu navegador.


🔒 Seguridad y Privacidad

APIEye está diseñado para ser seguro:

  1. Sanitización: Los campos definidos en sensitive_headers son reemplazados automáticamente por ***REDACTED*** antes de guardarse en la base de datos. Esto aplica tanto a Headers como a cuerpos JSON anidados.
  2. Modo Local: Al usar SQLite, los datos nunca salen de tu servidor. Tú tienes el control total de los logs.

📝 Requerimientos del Sistema

  • Node.js v14 o superior.
  • Express.js v4.17 o superior.

📄 Licencia

Este proyecto está bajo la licencia ISC.