Gathering detailed insights and metrics for miconfig
Gathering detailed insights and metrics for miconfig
Gathering detailed insights and metrics for miconfig
Gathering detailed insights and metrics for miconfig
npm install miconfig
Typescript
Module System
Min. Node Version
Node Version
NPM Version
64.5
Supply Chain
99.2
Quality
75.7
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
20,015
Last Day
20
Last Week
57
Last Month
296
Last Year
3,295
MIT License
6 Stars
51 Commits
3 Watchers
1 Branches
2 Contributors
Updated on Jan 23, 2023
Minified
Minified + Gzipped
Latest Version
1.1.6
Package Id
miconfig@1.1.6
Unpacked Size
8.83 kB
Size
3.68 kB
File Count
4
NPM Version
9.8.1
Node Version
18.18.2
Published on
Oct 24, 2023
Cumulative downloads
Total Downloads
Last Day
900%
20
Compared to previous day
Last Week
-20.8%
57
Compared to previous week
Last Month
-20.9%
296
Compared to previous month
Last Year
-20.9%
3,295
Compared to previous year
miconfig — Configuration loader for Node.js, browsers & Deno.
1$ npm install miconfig --save
In miconfig, a configuration is identified by environment name.
Place the configuration files wherever you desire, e.g., in a folder called config
:
1. 2├── index.js 3└── config 4 ├── default.js 5 ├── production.js 6 ├── staging.js 7 └── test.js
Then, load them using miconfig:
1const loadConfig = require('miconfig') 2 3const FILES = [ 4 'default', 5 NODE_ENV === 'development' ? undefined : NODE_ENV 6].filter(Boolean) 7 8const environment = FILES.reduce((acc, key) => { 9 acc[key] = require(`./config/${key}`) 10 return acc 11}, {}) 12 13const config = loadConfig(environment)
In case you want to use a different file format (like YAML), you've to parser them before be loaded:
1const environment = FILES.reduce((acc, key) => { 2 acc[key] = fromYaml(`./config/${key}.yml`) 3 return acc 4}, {})
The default
configuration is always loaded and merged with the target configuration environment.
miconfig uses process.env.NODE_ENV
to determine what configuration should be loaded.
In case you want to use a different source of truth, you can pass it as second argument:
1const loadConfig = require('miconfig') 2 3const config = loadConfig( 4 { 5 default: require('./config/default'), 6 production: require('./config/default') 7 }, 8 process.env.APP_ENV 9)
After miconfig loads your configuration, you can safely access to any value.
1// read a value, don't care if it's empty 2const database = config.get('database.url')
1// read a value, use a default if empty 2const database = config.get('database.url', 'localhost')
1// read a value, throw an error if it doesn't exist 2const database = config.require('database.url')
1// check if a value exists 2if (config.has('feature.prerender')) { 3 console.log('prerender is enabled') 4}
Additionally, you can retrieve more than one value at one time with destructuring assignment:
1// read multiple values, don't care if it's empty 2const { timezone, database } = config
1// read multiple values, throw an error if one of them doesn't exist 2const { timezone, database } = config.required
miconfig © Kiko Beats, released under the MIT License. Logo by Absurd Design.
Authored and maintained by Kiko Beats with help from contributors.
kikobeats.com · GitHub Kiko Beats · Twitter @Kikobeats
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/19 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-05-19
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More