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

@barelyacompany/locko

v1.1.0

Published

Node.js SDK for Locko — secrets and config management

Readme

locko

Official Node.js SDK for Locko — a secrets and config management tool.

Requirements

  • Node.js 18 or later (uses native fetch)

Installation

npm install locko

Quick start

You need an API key to fetch config. The API key is the one credential you must supply yourself — as a real environment variable, a CI secret, or a vault entry. It authenticates the request to Locko; it cannot come from Locko itself.

Fetch your config and wire it up explicitly. This keeps your dependencies clear and your code testable.

import { createClient } from "locko";

// LOCKO_API_KEY must already be set before this runs
const client = createClient({ apiKey: process.env.LOCKO_API_KEY! });

// All entries (secrets + plain variables) as a flat map
const config = await client.getConfig();

const db = new DataSource({ url: config.DATABASE_URL });
const redis = new Redis(config.REDIS_URL);

Fetching specific subsets

// Only secret entries
const secrets = await client.getSecrets();

// Only plain (non-secret) variables
const vars = await client.getVariables();

Injecting into process.env (optional)

If your codebase already reads broadly from process.env and you want Locko values to be picked up automatically, you can inject them in. Call this before any module that reads process.env.

await client.injectIntoEnv();          // won't overwrite existing keys
await client.injectIntoEnv({ override: true }); // force-overwrite

Configuration

| Option | Type | Required | Description | | -------- | -------- | -------- | ---------------------- | | apiKey | string | Yes | Your Locko API key |

API

createClient(options)LockoClient

Convenience factory that creates and returns a LockoClient instance.


new LockoClient(options)

Constructs a new client. Throws synchronously if apiKey is empty or missing.


client.getConfig()Promise<Record<string, string>>

Fetches all config entries (both secrets and plain variables) and returns them as a flat { key: value } map.

const config = await client.getConfig();
// { DATABASE_URL: "postgres://...", JWT_SECRET: "..." }

client.getSecrets()Promise<Record<string, string>>

Fetches config entries and returns only those where secret: true.

const secrets = await client.getSecrets();
// { JWT_SECRET: "..." }

client.getVariables()Promise<Record<string, string>>

Fetches config entries and returns only those where secret: false.

const vars = await client.getVariables();
// { DATABASE_URL: "postgres://...", PORT: "3000" }

client.injectIntoEnv(options?)Promise<void>

Fetches all entries and writes them into process.env. Existing keys are not overwritten unless { override: true } is passed.

await client.injectIntoEnv();          // safe — won't clobber existing env
await client.injectIntoEnv({ override: true }); // force-overwrite everything

Error handling

The SDK throws two kinds of errors:

| Error class | When thrown | | -------------- | --------------------------------------------------------------------------- | | LockoApiError | The API responded with a non-2xx HTTP status. Exposes a statusCode field. | | Error | Network failure, or unexpected response shape. |

import { createClient, LockoApiError } from "locko";

try {
  const config = await client.getConfig();
} catch (err) {
  if (err instanceof LockoApiError) {
    console.error(`API error ${err.statusCode}: ${err.message}`);
  } else {
    console.error("Network or parse error:", err);
  }
}

TypeScript

All types are included. The exported ConfigEntry interface mirrors the raw API response shape:

interface ConfigEntry {
  key: string;
  value: string;
  secret: boolean;
}

License

MIT