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

logbee-sdk-js

v1.0.1

Published

<div align="center"> <img src="https://products-wilbby.s3.eu-west-3.amazonaws.com/1747753527279-assets-wilbby" alt="Logbee Logo" width="200" />

Readme

🚀 Logbee SDK

npm version install size npm downloads License: MIT


📋 Table of Contents


🚀 Installation

Logbee SDK is extremely easy to integrate into your application. Start by installing the package:

# Using NPM
npm install logbee-sdk-js

# Using Yarn
yarn add logbee-sdk-js

# Using PNPM
pnpm add logbee-sdk-js

# Using bun
bun install logbee-sdk-js

⚙️ Quick Setup

To start using Logbee SDK in your application, you only need a few lines of code. The connection URL is predefined, you only need to provide your authentication token:

import { LogbeeHttpMonitor } from 'logbee-sdk-js';

// Create monitor with just your authentication token
const monitor = new LogbeeHttpMonitor({
  clientId: "proj_esdcsd";
  clientSecret: "secret_sdhcbjshdbc";
});

Then, simply integrate the middlewares in your application according to the framework you're using.


🧩 Frameworks

Express

import express from 'express';
import { LogbeeHttpMonitor } from 'logbee-sdk-js';

const app = express();

// Basic middlewares
app.use(express.json());

// Initialize Logbee
const monitor = new LogbeeHttpMonitor({
  clientId: "proj_esdcsd";
  clientSecret: "secret_sdhcbjshdbc";
  captureBody: true,
  captureHeaders: true,
  environment: process.env.NODE_ENV || 'development',
  serviceName: 'my-express-api'
});

// Middleware to capture all requests (before routes)
app.use(monitor.middleware());

// Application routes
app.get('/', (req, res) => {
  res.json({ message: 'Hello World!' });
});

// Error middleware (after all routes)
app.use(monitor.errorMiddleware());

app.listen(3000, () => {
  console.log('Express server running on port 3000');
});

NestJS

Request middleware (logger.middleware.ts)

import { Injectable, NestMiddleware } from '@nestjs/common';
import { LogbeeHttpMonitor } from 'logbee-sdk-js';

@Injectable()
export class LogbeeMiddleware implements NestMiddleware {
  private monitor: LogbeeHttpMonitor;

  constructor() {
    this.monitor = new LogbeeHttpMonitor({
      clientId: "proj_esdcsd";
      clientSecret: "secret_sdhcbjshdbc";
      captureBody: true,
      environment: process.env.NODE_ENV,
      serviceName: 'my-nestjs-api'
    });
  }

  use(req: any, res: any, next: () => void) {
    return this.monitor.middleware()(req, res, next);
  }
}

Exception filter (logbee-exception.filter.ts)

import { ExceptionFilter, Catch, ArgumentsHost, HttpException } from '@nestjs/common';
import { LogbeeHttpMonitor } from 'logbee-sdk-js';

@Catch()
export class LogbeeExceptionFilter implements ExceptionFilter {
  private monitor: LogbeeHttpMonitor;

  constructor() {
    this.monitor = new LogbeeHttpMonitor({
      clientId: "proj_esdcsd";
      clientSecret: "secret_sdhcbjshdbc";
      captureBody: true,
      environment: process.env.NODE_ENV,
      serviceName: 'my-nestjs-api'
    });
  }

  catch(exception: unknown, host: ArgumentsHost) {
    const ctx = host.switchToHttp();
    const req = ctx.getRequest();
    const res = ctx.getResponse();

    // Send error to Logbee
    this.monitor.errorMiddleware()(exception, req, res, () => {});

    // Normal error response
    const status =
      exception instanceof HttpException
        ? exception.getStatus()
        : 500;

    res.status(status).json({
      statusCode: status,
      timestamp: new Date().toISOString(),
      message: exception instanceof Error ? exception.message : 'Internal Server Error',
    });
  }
}

Module configuration (app.module.ts)

import { Module, MiddlewareConsumer, RequestMethod } from '@nestjs/common';
import { LogbeeMiddleware } from './logbee.middleware';
import { APP_FILTER } from '@nestjs/core';
import { LogbeeExceptionFilter } from './logbee-exception.filter';

@Module({
  providers: [
    {
      provide: APP_FILTER,
      useClass: LogbeeExceptionFilter,
    },
  ],
})
export class AppModule {
  configure(consumer: MiddlewareConsumer) {
    consumer
      .apply(LogbeeMiddleware)
      .forRoutes({ path: '*', method: RequestMethod.ALL });
  }
}

Koa

import Koa from 'koa';
import Router from 'koa-router';
import bodyParser from 'koa-bodyparser';
import { LogbeeHttpMonitor } from 'logbee-sdk-js';

const app = new Koa();
const router = new Router();

// Initialize Logbee
const monitor = new LogbeeHttpMonitor({
  clientId: "proj_esdcsd";
  clientSecret: "secret_sdhcbjshdbc";
  serviceName: 'my-koa-api',
  environment: process.env.NODE_ENV
});

// Middleware to capture all requests
app.use(async (ctx, next) => {
  const req = ctx.req;
  const res = ctx.res;
  const koaNext = async () => {
    try {
      await next();
    } catch (error) {
      // Capture and forward the error
      monitor.errorMiddleware()(error, req, res, () => {});
      throw error;
    }
  };

  // Adapt to Logbee middleware
  monitor.middleware()(req, res, koaNext);
});

app.use(bodyParser());
app.use(router.routes());
app.use(router.allowedMethods());

// Routes
router.get('/', (ctx) => {
  ctx.body = { message: 'Hello World!' };
});

app.listen(3000, () => {
  console.log('Koa server running on port 3000');
});

Fastify

import fastify from 'fastify';
import { LogbeeHttpMonitor } from 'logbee-sdk-js';

const app = fastify({ logger: true });

// Initialize Logbee
const monitor = new LogbeeHttpMonitor({
  clientId: "proj_esdcsd";
  clientSecret: "secret_sdhcbjshdbc";
  serviceName: 'my-fastify-api',
  environment: process.env.NODE_ENV
});

// Adapter for Fastify
app.addHook('onRequest', (request, reply, done) => {
  // Adapt Fastify objects to Logbee's expected format
  const req = {
    ...request.raw,
    method: request.method,
    originalUrl: request.url,
    body: request.body,
    headers: request.headers,
    query: request.query,
    params: request.params
  };

  const res = reply.raw;

  // Apply middleware
  monitor.middleware()(req, res, done);
});

// Error handler
app.setErrorHandler((error, request, reply) => {
  // Adaptation for error monitor
  const req = {
    ...request.raw,
    method: request.method,
    originalUrl: request.url,
    body: request.body,
    headers: request.headers
  };

  const res = reply.raw;

  // Send error to Logbee
  monitor.errorMiddleware()(error, req, res, () => {});

  // Normal response to client
  reply
    .status(error.statusCode || 500)
    .send({
      statusCode: error.statusCode || 500,
      error: error.name,
      message: error.message
    });
});

// Routes
app.get('/', async () => {
  return { message: 'Hello World!' };
});

// Test error route
app.get('/error', async () => {
  throw new Error('Test error');
});

// Start server
app.listen({ port: 3000 }, (err) => {
  if (err) {
    app.log.error(err);
    process.exit(1);
  }
});

Hapi

import Hapi from '@hapi/hapi';
import { LogbeeHttpMonitor } from 'logbee-sdk-js';

async function start() {
  const server = Hapi.server({
    port: 3000,
    host: 'localhost'
  });

  // Initialize Logbee
  const monitor = new LogbeeHttpMonitor({
    clientId: "proj_esdcsd";
    clientSecret: "secret_sdhcbjshdbc";
    serviceName: 'my-hapi-api',
    environment: process.env.NODE_ENV
  });

  // Plugin for Logbee
  const logbeePlugin = {
    name: 'logbee',
    register: async (server) => {
      // Extension for requests
      server.ext('onRequest', (request, h) => {
        const req = {
          method: request.method,
          originalUrl: request.url.href,
          headers: request.headers,
          body: request.payload
        };

        const res = {
          statusCode: 200,
          headersSent: false,
          setHeader: (name, value) => {},
          on: (event, callback) => {}
        };

        monitor.middleware()(req, res, () => {});

        return h.continue;
      });

      // Extension for errors
      server.events.on('request', (request, event, tags) => {
        if (tags.error) {
          const error = event.error;

          const req = {
            method: request.method,
            originalUrl: request.url.href,
            headers: request.headers,
            body: request.payload
          };

          const res = {
            statusCode: 500,
            headersSent: false,
            setHeader: (name, value) => {},
            on: (event, callback) => {}
          };

          monitor.errorMiddleware()(error, req, res, () => {});
        }
      });
    }
  };

  await server.register(logbeePlugin);

  // Routes
  server.route({
    method: 'GET',
    path: '/',
    handler: () => {
      return { message: 'Hello World!' };
    }
  });

  // Test error route
  server.route({
    method: 'GET',
    path: '/error',
    handler: () => {
      throw new Error('Test error');
    }
  });

  await server.start();
  console.log('Hapi server running at', server.info.uri);
}

start().catch(err => {
  console.error('Error starting server:', err);
  process.exit(1);
});

🛠️ Configuration Options

Logbee SDK offers numerous options to customize its behavior:

| Option | Type | Default Value | Description | |--------|------|--------------|-------------| | clientId | string | undefined | Project ID for the Logbee API | | clientSecret | string | undefined | Project secret for the Logbee API | | captureBody | boolean | false | Captures the request body | | captureHeaders | boolean | false | Captures the request headers | | captureQueryParams | boolean | false | Captures query parameters | | maskSensitiveData | boolean | true | Hides sensitive data like passwords | | sensitiveFields | string[] | ['password', 'token', ...] | Fields to hide | | environment | string | 'development' | Application environment | | serviceName | string | 'api' | Service name | | minStatusCodeToCapture | number | 400 | Minimum status code to capture | | captureAllRequests | boolean | false | Captures all requests, not just errors | | retryAttempts | number | 3 | Retry attempts if sending fails | | retryDelay | number | 1000 | Milliseconds between retries | | timeout | number | 5000 | Timeout for requests to Logbee |

Complete configuration example:

const monitor = new LogbeeHttpMonitor({
  clientId: 'your-clientId',
  clientSecret: 'your-clientSecret',
  captureBody: true,
  captureHeaders: true,
  captureQueryParams: true,
  maskSensitiveData: true,
  sensitiveFields: ['password', 'token', 'secret', 'authorization', 'key', 'apiKey', 'credit_card'],
  environment: 'production',
  serviceName: 'payment-api',
  minStatusCodeToCapture: 400,
  captureAllRequests: false,
  retryAttempts: 3,
  retryDelay: 1000,
  timeout: 5000
});

🔐 Security

Logbee SDK is designed with security as a priority:

  • ✅ Sensitive data is automatically masked
  • ✅ Communications are done over HTTPS
  • ✅ No information is stored on disk
  • ✅ Secure token authentication
  • ✅ Does not affect your application's performance

📊 Dashboard

With your Logbee account, you get access to a comprehensive dashboard where you can:

  • 📈 View real-time error graphs
  • 🔍 Search and filter logs by various criteria
  • 🔔 Configure custom alerts
  • 👥 Manage teams and permissions
  • 📱 Receive notifications via Slack, Teams, email, or SMS

📚 API Reference

For complete details on available methods and properties, see our complete API documentation.

Main methods:

  • constructor(options) - Creates a new monitor instance
  • middleware() - Returns a middleware to capture requests
  • errorMiddleware() - Returns a middleware to capture errors
  • setToken(token) - Updates the authentication token
  • setEndpoint(url) - Changes the Logbee endpoint

❓ FAQ


WebsiteDocumentationBlogTwitterDiscord