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

@veresk-tool/nodejs

v0.0.2

Published

Remote configuration and feature flag client for Veresk in Node.js

Readme

@veresk-tool/nodejs

@veresk-tool/nodejs is a Node.js client for Veresk remote files and feature-flag/config payloads.

It downloads manifests and file contents from one or more CDN endpoints, keeps them in memory, emits update events, and ships with a lightweight mock for tests.

Installation

npm install @veresk-tool/nodejs

Requirements

  • Node.js 18+
  • HTTPS-accessible Veresk CDN endpoints in production

Quick Start

import { Veresk, VereskEventName } from '@veresk-tool/nodejs';

type FeatureFlags = Record<string, boolean>;

type Experiment = {
  name: string;
  enabled: boolean;
};

const veresk = new Veresk({
  cdnUrls: ['https://cdn.example.com'],
  version: 'default',
  consumer: 'common',
  expireMs: 60_000,
  fetchRetryCount: 1,
  fetchTimeout: 1_500,
  encryptSecret: process.env.VERESK_SECRET,
});

veresk.on(VereskEventName.Error, (error) => {
  console.error(error);
});

veresk.on(VereskEventName.ManifestFetched, (event) => {
  console.log('manifest status', event);
});

veresk.on(VereskEventName.FileUpdated, ({ name, etag }) => {
  console.log(`updated ${name} (${etag})`);
});

await veresk.init();

const featureFlags = veresk.getContent<FeatureFlags>('featureFlags');

const experiments = await veresk.fetchContent<Experiment[]>('experiments');

const enabledExperiment = veresk.getAsListOrThrow<Experiment[]>('experiments', {
  find: { name: 'checkout-redesign' },
});

API

new Veresk(options)

Available options:

  • cdnUrls: string[] required. Ordered list of CDN base URLs.
  • version: string required. Files version to load.
  • consumer: string required. Default consumer for this client instance.
  • expireMs?: number polling interval for manifest refresh. Default: 60000.
  • fetchRetryCount?: number additional retry attempts across configured CDNs. Default: 0.
  • fetchTimeout?: number timeout per HTTP request in milliseconds. Default: 1500.
  • encryptSecret?: string shared secret for encrypted file payloads.
  • log?: ILog custom logger with log, warn, and error.

await veresk.init()

Loads the initial manifest and files package, then starts background polling.

veresk.reset()

Stops polling, removes listeners, and clears loaded packages from memory.

await veresk.fetchManifest(consumer)

Ensures the package for consumer is loaded and returns:

{
  etag: string;
  manifest: TManifest;
  contentUrls: string[];
}

veresk.getManifest(consumer)

Returns the last loaded manifest from memory.

await veresk.fetchContent(name, options?)

Ensures data is loaded for the target consumer, then returns file content.

Use it like this:

  • fetchContent<MyObject>('featureFlags') for a non-array file
  • fetchContent<MyItem[]>('experiments') for the whole array file
  • fetchContent<MyItem>('experiments', { filter: { enabled: true } }) for a filtered array
  • fetchContent<MyItem>('experiments', { find: { name: 'checkout-redesign' } }) for a single matching array item

Options:

  • consumer?: string
  • filter?: Partial<T>
  • find?: Partial<T> | ((item: T) => boolean)

When find is used, the method throws if no item matches.

veresk.getContent(name, consumer?)

Returns the raw file content from memory without network IO.

This is the lowest-level getter and works for both singleton and array-shaped files.

veresk.getAsList(name, options?)

Convenience helper for array-shaped files already loaded in memory.

Behavior:

  • without find it returns the whole array
  • with filter it returns a filtered array
  • with find it returns a single item or undefined

If the file content is not an array, the method throws.

Example:

type Experiment = {
  name: string;
  enabled: boolean;
};

const experiments = veresk.getAsList<Experiment[]>('experiments', {
  filter: { enabled: true },
});

veresk.getAsListOrThrow(name, options?)

Same as getAsList, but when find is used it throws if no item matches.

Example:

type Experiment = {
  name: string;
  enabled: boolean;
};

const experiment = veresk.getAsListOrThrow<Experiment[]>('experiments', {
  find: { name: 'checkout-redesign' },
});

Events

The client emits these events:

  • file-updated with { name, consumer, etag, data }
  • manifest-fetched with { success, uri, time, changed }
  • error with ManifestNotFoundError | FetchFileError

The package exports VereskEventName if you prefer constants over string literals.

Test Mocks

Use VereskMock to test consumers without network access:

import { VereskMock } from '@veresk-tool/nodejs';

type Item = {
  id: number;
  name: string;
};

const veresk = new VereskMock({
  items: [
    { id: 0, name: 'item-0' },
    { id: 1, name: 'item-1' },
  ],
});

const item = veresk.getAsListOrThrow<Item[]>('items', {
  find: { id: 0 },
});

VereskMock uses the same read API as Veresk, so test code can usually stay unchanged.

Security Notes

  • Prefer https:// CDN URLs in production.
  • Treat remote file contents as untrusted input and validate shapes in application code.
  • If you use encrypted files, protect encryptSecret the same way you protect other application secrets.