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

@linplatform/lin-configuration

v1.0.0

Published

Dynamic remote configuration loader for Node.js applications.

Readme

@linplatform/lin-configuration

Dynamic remote configuration loader for Node.js applications. It fetches a remote JSON configuration and maps each value into process.env, inspired by .NET IConfigurationProvider.

Features

  • Native fetch on Node.js 18+
  • TypeScript-first API
  • Optional in-memory cache
  • Optional auto-refresh
  • Optional debug logs
  • Response validation and robust error handling
  • overrideExisting support
  • Optional key prefix
  • Optional key transform hook
  • Optional validation hook per entry
  • Dual package export for ESM and CommonJS

Installation

npm install @linplatform/lin-configuration

Quick Start

ESM / TypeScript

import { loadRemoteConfig } from "@linplatform/lin-configuration";

await loadRemoteConfig({
  apiKey: "MI_API_KEY",
  overrideExisting: true,
});

console.log(process.env.MI_VARIABLE);

CommonJS

const { loadRemoteConfig } = require("@linplatform/lin-configuration");

async function bootstrap() {
  await loadRemoteConfig({
    apiKey: "MI_API_KEY",
    overrideExisting: true,
  });

  console.log(process.env.MI_VARIABLE);
}

bootstrap();

API

loadRemoteConfig(options)

Loads configuration from the remote API and assigns the valid entries to process.env.

import { loadRemoteConfig } from "@linplatform/lin-configuration";

await loadRemoteConfig({
  apiKey: "MI_API_KEY",
  url: "https://api.linplatform.com/configuration/api/configuration",
  overrideExisting: false,
  useCache: true,
  cacheTtlMs: 300000,
  refreshIntervalMs: 600000,
  debug: false,
  prefix: "APP_",
  transformKey: (key) => key.toUpperCase(),
  validateEntry: ({ key, value }) => key.length > 0 && value.length > 0,
});

Options

| Option | Type | Required | Default | Description | | --- | --- | --- | --- | --- | | apiKey | string | Yes | - | API key sent in the key header. | | url | string | No | https://api.linplatform.com/configuration/api/configuration | Remote endpoint to fetch configuration from. | | overrideExisting | boolean | No | false | When true, existing process.env values are overwritten. | | useCache | boolean | No | true | Enables in-memory response cache. | | cacheTtlMs | number | No | 300000 | Cache lifetime in milliseconds. Use 0 to keep cache forever during process lifetime. | | refreshIntervalMs | number | No | undefined | Enables periodic reload using setInterval. | | debug | boolean | No | false | Emits debug logs through console.debug. | | prefix | string | No | "" | Prefix applied to every environment variable name. | | transformKey | (key: string) => string | No | - | Transforms each remote key before assignment. | | validateEntry | (entry) => boolean \| void \| Promise<boolean \| void> | No | - | Called before assigning each entry. Return false to skip the key. |

Response Shape

Expected remote response:

{
  "KEY1": "value1",
  "KEY2": "value2"
}

Behavior:

  • null and undefined values are ignored
  • Non-string values throw an error
  • Invalid JSON throws an error
  • Non-2xx responses throw an error

Examples

Prefix and key normalization

import { loadRemoteConfig } from "@linplatform/lin-configuration";

await loadRemoteConfig({
  apiKey: "MI_API_KEY",
  prefix: "APP_",
  transformKey: (key) => key.toUpperCase(),
});

console.log(process.env.APP_DATABASE_URL);

Skip existing environment variables

process.env.PORT = "3000";

await loadRemoteConfig({
  apiKey: "MI_API_KEY",
  overrideExisting: false,
});

console.log(process.env.PORT); // keeps "3000"

Auto-refresh every 5 minutes

import {
  loadRemoteConfig,
  stopRemoteConfigAutoRefresh,
} from "@linplatform/lin-configuration";

await loadRemoteConfig({
  apiKey: "MI_API_KEY",
  refreshIntervalMs: 5 * 60 * 1000,
  overrideExisting: true,
});

// Later, if needed:
stopRemoteConfigAutoRefresh({ apiKey: "MI_API_KEY" });

Custom validation hook

await loadRemoteConfig({
  apiKey: "MI_API_KEY",
  validateEntry: ({ key, value }) => {
    if (!key.startsWith("APP_")) {
      return false;
    }

    return value.trim().length > 0;
  },
});

Additional Utilities

clearRemoteConfigCache()

Clears the in-memory cache.

stopRemoteConfigAutoRefresh(options?)

Stops one refresh timer or all refresh timers.

import { stopRemoteConfigAutoRefresh } from "@linplatform/lin-configuration";

stopRemoteConfigAutoRefresh({ apiKey: "MI_API_KEY" });
stopRemoteConfigAutoRefresh();

getRemoteConfigCacheSnapshot()

Returns a read-only snapshot of cached entries.

Error Handling

The package throws RemoteConfigError for:

  • Missing or invalid apiKey
  • Invalid url
  • HTTP request failures
  • Non-success HTTP status codes
  • Invalid JSON
  • Invalid response shape
  • Invalid refresh or cache options

Example:

import { loadRemoteConfig, RemoteConfigError } from "@linplatform/lin-configuration";

try {
  await loadRemoteConfig({ apiKey: "MI_API_KEY" });
} catch (error) {
  if (error instanceof RemoteConfigError) {
    console.error(error.message);
  }
}

Build

npm run build

The build generates:

  • dist/esm
  • dist/cjs
  • dist/types

License

MIT