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

ac-bootstrap-elasticsearch

v2.0.12

Published

OpenSearch (ElasticSearch) init for AC apps

Readme

ac-bootstrap-elasticsearch

Initializes OpenSearch/ElasticSearch client instances and attaches them to acapi.elasticSearch for use across an AC application.

Node.js CI CodeQL

Installation

yarn add ac-bootstrap-elasticsearch

Usage

const esBootstrap = require('ac-bootstrap-elasticsearch')(acapi)

// Initialize all configured indices (called once at app startup)
await esBootstrap.init()

// In tests: reset an index and optionally rebuild its mapping
await esBootstrap.prepareForTest({ instance: 'books', createMapping: myMappingFn })

Configuration

The module reads from acapi.config.elasticSearch:

acapi.config.elasticSearch = {
  timeout: 30000, // request timeout in ms (default: 30000)
  servers: [
    {
      server: 'cluster',       // unique name, referenced by indices
      host: 'localhost',
      port: 9243,
      protocol: 'https',
      auth: 'username:password', // optional
      awsCluster: false          // set true to enable AWS Sigv4 signing
    }
  ],
  indices: [
    {
      model: 'books',      // used to build the index name and look up the instance
      server: 'cluster',   // must match a server name above
      instance: 'books',   // key under acapi.elasticSearch where the client is stored
      indexInfix: 'books', // optional – overrides model in the index name
      global: false,       // true = no environment prefix in the index name
      omitInTest: false    // true = skip this index when environment === 'test'
    }
  ]
}

Index naming

The resolved index name follows this pattern:

[environment_][NODE_TEST_ORIGIN_][indexInfix|model]

| Config | Result | |---|---| | model: 'books', env staging | staging_books | | model: 'books', env staging, NODE_TEST_ORIGIN=pr42 | staging_pr42_books | | model: 'books', global: true | books | | indexInfix: 'catalog', env production | production_catalog |

AWS / OpenSearch Service

Set awsCluster: true on a server entry to enable AWS Sigv4 request signing. Credentials are resolved via the standard AWS SDK credential chain (@aws-sdk/credential-provider-node).

{ server: 'aws', host: 'search-….es.amazonaws.com', port: 443, protocol: 'https', awsCluster: true }

Local override

Set acapi.config.localElasticSearch to override the host/port/protocol for a local tunnel or dev environment:

acapi.config.localElasticSearch = { host: '127.0.0.1', port: 9200, protocol: 'http' }

API

init()

Connects to all configured servers and attaches the clients to acapi.elasticSearch[instance]. Indices with omitInTest: true are skipped when environment === 'test'. Returns a log-collector array.

prepareForTest({ instance, createMapping })

Resets an index for test isolation:

  1. Checks for an in-progress cluster snapshot and waits if one is found.
  2. Deletes all index variants matching <indexName>*.
  3. If createMapping is provided, creates a fresh UUID-named index, calls createMapping({ index, model }), then adds an alias pointing back to the configured index name.

Tests

yarn test

Tests use Mocha and Sinon with Node's built-in assert module. No real OpenSearch connection is required.

License

MIT, Copyright AdmiralCloud AG