
Product
Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
typed-configs
Advanced tools
Library for accessing your config variables in a typed manner, with runtime checking and a definition exporter. Supports .yml and enviroment variables.
Library for accessing your config variables in a typed manner, with runtime checking and a definition exporter. Supports .yml and enviroment variables.
In your index.ts
of your project, add import "reflect-metadata";
Create a config file like this:
import { Config, ConfigValue } from "typed-configs";
@Config({ configYmlPath: "configs/test.yml", ignoreEmptyValues: false })
export class Communicator {
@ConfigValue({
name: "GREETING",
description: "They way you say hi to others",
required: true,
recommendedValue: "Hello"
})
greeting!: string;
@ConfigValue({
name: "GOODBYE_MESSAGE",
description: "The way you say goodbye. Optional.",
required: false
})
goodbye: string = "/me left the chat";
@ConfigValue({
name: "IDLE_SOUND",
description: "What do you say when doing nothing?",
required: false
})
idleMessage?: string;
@ConfigValue({
name: "AGE",
description: "The driver age. should be greater than 18.",
required: false,
validate: (age: number) => age >= 18
})
age?: number;
nonConfigProperty = "I don't need a type because I don't matter.";
}
Use the config class somewhere in your code so the decorators get a chance to register the class and its properties.
import { Configs } from "typed-configs";
console.log(`User says: ${Configs.get(Communicator).greeting}`);
Export the config definition to an actual file (optional but kinda the goal of this library to support this). The Configs.getConfigsDefinitions()
method is to know for sure all the decorators have been processed.
import * as fs from "fs";
import { Configs } from "./ConfigManager";
Configs.getConfigsDefinitions().then(definitions => {
fs.writeFileSync("configDefinitions.json", JSON.stringify(definitions));
});
string
, number
and boolean
are currently supported.goodbye?: string;
is allowed, but goodbye: string | undefined;
isn't. reflect-metadata
will give the first one type String
and the latter Object
(which isn't allowed by the library).greeting
in our example), you can use an exclamation mark (like greeting!: string;
) to make the types still work. The library will prevent your program to start if the value isn't provided.FAQs
Library for accessing your config variables in a typed manner, with runtime checking and a definition exporter. Supports .yml and enviroment variables.
The npm package typed-configs receives a total of 1 weekly downloads. As such, typed-configs popularity was classified as not popular.
We found that typed-configs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.