Installations
npm install config.ts
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
9.8.0
NPM Version
5.6.0
Score
65.4
Supply Chain
82.7
Quality
74.7
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (68.32%)
JavaScript (31.68%)
Developer
illberoy
Download Statistics
Total Downloads
11,716
Last Day
2
Last Week
39
Last Month
216
Last Year
2,465
GitHub Statistics
6 Stars
3 Commits
1 Forks
2 Watching
2 Branches
1 Contributors
Package Meta Information
Latest Version
1.0.0
Package Id
config.ts@1.0.0
Unpacked Size
24.09 kB
Size
7.46 kB
File Count
24
NPM Version
5.6.0
Node Version
9.8.0
Total Downloads
Cumulative downloads
Total Downloads
11,716
Last day
0%
2
Compared to previous day
Last week
-23.5%
39
Compared to previous week
Last month
70.1%
216
Compared to previous month
Last year
-24%
2,465
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
7
📚 Transparent, typesafe environment configuration
Most of today's configuration systems rely on environment variables, json
files or other rc
formats. While usually those methods deliver, they have one problem: since we do not commit config files, their structure and usage are implicit. What guarantee do we have in run time, that process.env.SERVER_PORT
is set and valid?
Config.ts
comes to change that.
With Config.ts
you define the template of the configuration file and use it to generate configurations everywhere. Config.ts
contains these awesome features:
- ✅ Runtime validation of the configuration existence and shape!
- 📐 Fully typed configuration object in your code! (if you use typescript)
- 📝 A cute little CLI to configure your projects when deploying!
- 🦄 Unicorns!
Quick Start
First, install Config.ts
using npm:
1npm install config.ts
Create a ./config.ts
file in your project root, e.g:
1import { loadConfig } from 'config.ts'; 2 3export default loadConfig({ 4 SERVER_PORT: 'number', 5 IS_PUBLIC: 'boolean', 6 SECRET_KEY: 'string' 7});
Use your configuration everywhere in your code by importing it from the ./config.ts
file:
When deploying, configure using the comfortable Config.ts
cli, by running npx configts
:
This will create a ./.config
file in your project root, which is the actual configuration json file and therefore should not be committed, so the last step is to add .config
to your .gitignore
file (or any other vcs ignore files);
The config.ts
file
The ./config.ts
file is actually the configuration template. You define it using the loadConfig
function. Config.ts
expects this file to export the loaded configuration as an export default
, so it can be used both by your code and by the Config.ts
cli.
The loadConfig
function
The loadConfig
function expects an object which describes the structure of the configuration. The object contains the keys and type of the configuration, where the available types are string
, number
or boolean
.
Importing config.ts
file in your code
In order to use the configuration in your code, simply import it from the ./config.ts
file in your project root. The way loadConfig
is defined will ensure that you get a fully typed configuration object in your code. In runtime, loadConfig
ensures that a configuration json exists in ./.config
, and that the types match the schema it is defined with, and populates the object it exports with that json.
Contribution
Suggestions, issue reports and pull requests are always welcome.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: ISC License: LICENSE:0
Reason
0 existing vulnerabilities detected
Reason
Found 0/3 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
3
/10
Last Scanned on 2024-12-23
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