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

@linnovate/blocktree

v2.0.1

Published

Tools for developers, to build services with a uniform standard (node_modules/envs/logs).

Readme

@linnovate/blocktree

Blocktree Core is a suite of robust, standardized tools for Node.js developers. It simplifies the creation of microservices and applications by providing pre-configured wrappers for common infrastructure (databases, logging, security, APIs) with a focus on uniform logging, environment variable configuration, and best practices.

Installation

yarn add @linnovate/blocktree
# or
npm install @linnovate/blocktree

Documentation

Detailed documentation for each module can be found in the docs/ folder:

  • General Utilities: Structured Logger (Pino), Fetch Client, JWT Parsing, and Dynamic Imports, and PromiseOnce, and JwtSession session-handler.
  • Server Utilities: Express middlewares for security (Helmet/CORS), optimization, and Swagger auto-generation, and JwtSessionExpress session-handler.
  • GraphQL: Yoga Server setup, Clients, and Security (Armor).
  • MongoDB: Client connection and Zero-Downtime Indexing (Blue/Green deployment).
  • Elasticsearch / OpenSearch: Clients and Zero-Downtime Indexing utilities.
  • Services: Clients for Redis, MySQL, RabbitMQ, S3/Google Storage, JSON:API, and Mailer.

Quick Start

1. Basic Server Setup

Blocktree helps you bootstrap an Express server with security, optimization, and documentation in just a few lines.

import express from 'express';
import { 
  Logger, 
  SecurityExpress, 
  OptimizeExpress, 
  SwaggerExpress 
} from '@linnovate/blocktree';

const app = express();
app.listen(3000, () => console.log('Server running on port 3000'));

// Initialize Logger
await Logger({ LOG_SERVICE_NAME: 'my-service', DEBUG: 'blocktree:*' });

// Apply standard middleware
SecurityExpress(app); // Helmet, CORS, RateLimiter
OptimizeExpress(app); // Compression
SwaggerExpress(app);  // Auto-generated API docs at /api-docs

2. Database Connection (Singleton Pattern)

Blocktree helps you bootstrap an Express server with security, optimization, and documentation in just a few lines.

import { MongoClient, RedisClient } from '@linnovate/blocktree';

// Connect to Mongo (uses process.env.MONGO_URI)
const mongo = await MongoClient();
const db = mongo.db('my-db');

// Connect to Redis (uses process.env.REDIS_URI)
const redis = await RedisClient();
await redis.set('foo', 'bar');

Local Development & Testing

This repository includes a server.js and compose.yaml file designed for local development and testing of the library features.

Release Notes: v2.0.0

Version 2.0.0 represents a significant architectural overhaul of the Blocktree core. This release focuses on modernizing the codebase for Node.js 24+, improved project structure, advanced logging capabilities with namespace support, and enhanced zero-downtime indexing strategies for databases.

Breaking Changes

  • Node.js Requirement: The minimum required Node.js version is now >=24.0.0.
  • Removed Modules:
    • OpenIdExpress: This module has been removed from the core package.
    • AutoLoad: The standalone tool has been removed; auto-loading logic is now built directly into specific services like GraphqlServer.
  • Renamed/Replaced Functions:
    • OpenSearchClient is replaced by ElasticClient. Use ElasticClient({ useOpensearch: true }) to connect to OpenSearch.
    • GraphqlExpress is replaced by GraphqlServer.
    • ElasticIndexerExpress and MongoIndexerExpress are removed in favor of using ElasticIndexer and MongoIndexer tools directly or creating custom routes.
  • Logging Configuration: The Logger no longer relies on LOG_LEVEL. It now uses the standard DEBUG environment variable (e.g., DEBUG=blocktree:*) to control verbosity and namespaces.

New Features

  • JwtSessionExpress: A new middleware that handles session management using JWTs stored in cookies with reactive Proxy support for automatic re-signing.
  • PromiseOnce: Added PromiseOnce, a utility to prevent multiple concurrent executions of the same asynchronous operation (caching in-flight promises).
  • OptimizeExpress: Compression logic has been extracted from SecurityExpress into its own dedicated module.
  • Rate Limiting: SecurityExpress now includes express-rate-limit by default.
  • GraphQL Yoga v5: Upgraded underlying engine to Yoga v5.
  • GraphQL Armor: Integrated @escape.tech/graphql-armor for built-in security and protection against malicious queries.
  • Auto-Loading: GraphqlServer now natively supports auto-loading typeDefs, resolvers, and directives from specified directories.

Improvements & Refactoring

Logger & Debugging The logging system has been completely rewritten:

  • Trace ID (Request Scoping): A unique transaction/request ID, enabling effortless distributed tracing and debugging across asynchronous operations without manually passing a context object.
  • Namespaces: Logs are now categorized by namespaces (e.g., logger.debug('Some text', { namespace='MongoClient' })).
  • Configuration: Controlled via DEBUG env var (supports wildcards like blocktree:* or exclusions like -blocktree:Server).
  • Integration: All clients (Mongo, Elastic, Fetch, Redis) now automatically log request/response cycles with high detail in debug mode.

Database Clients

  • Singleton Pattern: Clients (MongoClient, RedisClient, ElasticClient, etc.) are now robust singletons keyed by their connection strings/options.
  • Mocking: Enhanced mocking support for testing (using mongodb-memory-server and @elastic/elasticsearch-mock).
  • Logging: Deep integration with the new Logger to trace commands, queries, and execution time.

Migration Guide

1. Updating Logger

// v1.5.0:
// .env: LOG_LEVEL=info
await Logger({ setupOptions: { ... } });

// v2.0.0:
// .env: DEBUG=blocktree:*
import { Logger } from '@linnovate/blocktree';
await Logger({ LOG_SERVICE_NAME: 'my-service' });

2. Setting up GraphQL

// v1.5.0 (`GraphqlExpress`):
GraphqlExpress(app, schemas, { serverWS, yogaOptions });

// v2.0.0 (`GraphqlServer`):
import { GraphqlServer } from '@linnovate/blocktree';
GraphqlServer(app, schemas, { ...yogaOptions });

3. Server Middleware

// v1.5.0:
SecurityExpress(app, { corsOptions, helmetOptions });

// v2.0.0:
import { SecurityExpress, OptimizeExpress } from '@linnovate/blocktree';
SecurityExpress(app); // Helmet, CORS, RateLimit
OptimizeExpress(app); // Compression (Separate call)

4. Indexer Callbacks (ElasticIndexer & MongoIndexer)

The function signatures for batchCallback and testCallback have changed from using positional arguments to a single object argument. This improves extensibility and consistency.

// v1.5.0:
const reports = await (ElasticIndexer||MongoIndexer)(
  { ... },
  async (offset, config, reports) => [],
  async (config, reports) => true
);

// v2.0.0:
const status = await (ElasticIndexer||MongoIndexer)(
  { ... },
  async ({ offset, index, mode, response }) => [],
  async ({ index, activeIndexName }) => true,
);

License

This project is licensed under the MIT License.