Skip to content

A simple utility for reading Skpr config in node applications.

Notifications You must be signed in to change notification settings

skpr/node-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@skpr/config

Lightweight config loader for SKPR that reads /etc/skpr/data/config.json, caches the data, and reloads only when the file modification time changes. Stat checks are throttled (default 1s) to reduce I/O.

  • Zero dependencies
  • ESM + CJS
  • Safe on malformed JSON (keeps last good config)
  • Customizable path and throttle
  • TypeScript types included

Install

npm i @skpr/config
pnpm add @skpr/config
yarn add @skpr/config

Usage

ESM

import skprConfig, { get, skprConfigGet, configure } from '@skpr/config';

configure({
  // path: '/etc/skpr/data/config.json', // default
  statThrottleMs: 500, // optional
});

// Load a config with a fallback
const apiSecret = skprConfig.get('api.secret') || 'fallback';

CommonJS

const skprConfig = require('@skpr/config');

skprConfig.configure({ statThrottleMs: 500 });

const apiSecret = skprConfig.get('api.secret') || 'fallback';

About

A simple utility for reading Skpr config in node applications.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors 2

  •  
  •