Gathering detailed insights and metrics for config.ts
Gathering detailed insights and metrics for config.ts
Gathering detailed insights and metrics for config.ts
Gathering detailed insights and metrics for config.ts
npm install config.ts
Typescript
Module System
Node Version
NPM Version
65.4
Supply Chain
82.7
Quality
74.7
Maintenance
100
Vulnerability
100
License
TypeScript (68.32%)
JavaScript (31.68%)
Total Downloads
11,716
Last Day
2
Last Week
39
Last Month
216
Last Year
2,465
6 Stars
3 Commits
1 Forks
2 Watching
2 Branches
1 Contributors
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
Cumulative downloads
Total Downloads
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
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:
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);
config.ts
fileThe ./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.
loadConfig
functionThe 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
.
config.ts
file in your codeIn 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.
Suggestions, issue reports and pull requests are always welcome.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
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
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
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