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

@dumanarge/xssrv-shared-lib

v1.0.3

Published

Shared library for DumanArge IoT Platform services — tracing, logging, health, outbox, auth, config

Readme

@dumanarge/xssrv-shared-lib

Shared infrastructure library for DumanArge IoT Platform NestJS microservices.

Provides production-ready modules for tracing, structured logging, health checks, transactional outbox pattern, multi-tenant isolation, audit trails, feature flags, and graceful shutdown.

Installation

npm install @dumanarge/xssrv-shared-lib

Peer Dependencies

This library uses peer dependencies to avoid version conflicts. Install the modules you need:

# Core (required)
npm install @nestjs/common @nestjs/core rxjs reflect-metadata

# Tracing (for OpenTelemetry support)
npm install @opentelemetry/sdk-node @opentelemetry/auto-instrumentations-node \
  @opentelemetry/exporter-trace-otlp-grpc @opentelemetry/exporter-metrics-otlp-grpc \
  @opentelemetry/resources @opentelemetry/sdk-metrics

# Logging
npm install nestjs-pino pino pino-http

# Health checks
npm install @nestjs/terminus

# Outbox & Tenant isolation
npm install @prisma/client

# Feature flags
npm install @nestjs/config

# Redis health indicator
npm install ioredis

Modules

Tracing (OpenTelemetry)

Bootstrap tracing before your NestJS app starts:

// main.ts — must be the FIRST import
import '@dumanarge/xssrv-shared-lib/tracing';

import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';

Use the @Span() decorator for custom business logic tracing:

import { Span } from '@dumanarge/xssrv-shared-lib';

@Injectable()
export class DeviceService {
  @Span('device.provision')
  async provisionDevice(dto: CreateDeviceDto) {
    // Automatically traced with OpenTelemetry
  }
}

Environment variables:

| Variable | Default | Description | |---|---|---| | SERVICE_NAME | unknown-service | OTel service name | | SERVICE_VERSION | 1.0.0 | OTel service version | | OTEL_EXPORTER_OTLP_ENDPOINT | http://localhost:4317 | OTel Collector endpoint | | OTEL_DEBUG | false | Enable OTel debug logging |


Logging (Pino + OTel)

import { LoggingModule } from '@dumanarge/xssrv-shared-lib';

@Module({
  imports: [LoggingModule],
})
export class AppModule {}

Features: JSON structured logs, automatic traceId/spanId injection, request correlation via X-Request-Id, sensitive field redaction, health endpoint filtering.


Health Checks

import { HealthModule } from '@dumanarge/xssrv-shared-lib';

@Module({
  imports: [HealthModule],
})
export class AppModule {}

Exposes GET /health/live (liveness) and GET /health/ready (readiness) endpoints for Kubernetes probes.

Custom health indicators included: RedisHealthIndicator, RabbitMQHealthIndicator.


Multi-Tenant Isolation

import {
  TenantMiddleware,
  TenantGuard,
  TenantContext,
  createPrismaTenantMiddleware,
} from '@dumanarge/xssrv-shared-lib';

// In AppModule
export class AppModule implements NestModule {
  configure(consumer: MiddlewareConsumer) {
    consumer.apply(TenantMiddleware).forRoutes('*');
  }
}

// In service — automatic tenant scoping for Prisma
prisma.$use(createPrismaTenantMiddleware(() => tenantContext.tenantId));

Outbox Pattern

Guaranteed event delivery via transactional outbox:

import { OutboxRepository, RabbitMQEventPublisher, OutboxWorker } from '@dumanarge/xssrv-shared-lib';

// Write event in the same DB transaction as business data
await prisma.$transaction(async (tx) => {
  await tx.tenant.create({ data: tenantData });
  await outboxRepo.createInTransaction(tx, {
    aggregateType: 'tenant',
    aggregateId: tenant.id,
    eventType: 'tenant.created',
    payload: tenantData,
  });
});

Audit Interceptor

Tamper-proof audit trail for all mutation operations (POST/PUT/PATCH/DELETE):

import { AuditInterceptor } from '@dumanarge/xssrv-shared-lib';

@Module({
  providers: [
    { provide: APP_INTERCEPTOR, useClass: AuditInterceptor },
  ],
})
export class AppModule {}

Feature Flags

Dynamic feature toggles via Consul KV with local cache fallback:

import { FeatureFlagService } from '@dumanarge/xssrv-shared-lib';

const isEnabled = await featureFlags.isEnabled('device_twin_enabled', tenantId);
const config = await featureFlags.getConfig('batch_signal_processing');

Graceful Shutdown

import { GracefulShutdownModule, enableGracefulShutdown } from '@dumanarge/xssrv-shared-lib';

// In AppModule
@Module({
  imports: [GracefulShutdownModule],
})
export class AppModule {}

// In main.ts
const app = await NestFactory.create(AppModule);
enableGracefulShutdown(app);

Sub-path Imports

You can import individual modules directly to minimize bundle:

import '@dumanarge/xssrv-shared-lib/tracing';
import { LoggingModule } from '@dumanarge/xssrv-shared-lib/logging';
import { HealthModule } from '@dumanarge/xssrv-shared-lib/health';
import { OutboxRepository } from '@dumanarge/xssrv-shared-lib/outbox';
import { TenantMiddleware } from '@dumanarge/xssrv-shared-lib/auth';
import { GracefulShutdownModule } from '@dumanarge/xssrv-shared-lib/config';

Requirements

  • Node.js >= 20
  • NestJS >= 11
  • TypeScript >= 5.7

License

MIT