Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@confconf/confconf
Advanced tools
Readme
confconf
is an opinionated library for loading and validating application configuration.
npm i --save @confconf/confconf
The library is used as follows:
Use @confconf/confconf-typebox
import { confconf, envConfig } from "@confconf/confconf";
type Config = {
port: number;
db: {
host: string;
name: string;
};
};
// Create the configuration loader
const configLoader = confconf<Config>({
schema: {
type: "object",
properties: {
port: { type: "number" },
db: {
type: "object",
properties: {
host: { type: "string" },
name: { type: "string" },
},
required: ["host", "name"],
},
},
required: ["port", "db"],
},
providers: [
// Load from env variables
envConfig({
// Map the specifc env variables into a specific structure
structure: {
port: "PORT",
db: {
host: "DB_HOST",
name: "DB_NAME",
},
},
}),
],
});
// Load configuration and validate it against the schema
const config = await configLoader.loadAndValidate();
Default values can be defined either using the JSON schema or by using the static configuration provider.
import { confconf } from "@confconf/confconf";
// Define a schema using JSON schema
const configSchema = {
type: "object",
properties: {
port: {
type: "number",
default: 3000,
},
},
required: ["port"],
};
import { confconf, staticConfig } from "@confconf/confconf";
// Define a schema using JSON schema
const configSchema = {
type: "object",
properties: {
port: { type: "number" },
},
required: ["port"],
};
const configLoader = confconf({
schema: configSchema,
providers: [
// Static config is loaded first, later defined providers can override its values
staticConfig({
port: 3000,
}),
// Other providers
],
});
The partial configurations are loaded from all the defined configuration providers when loadAndValidate
is called. After the partial configurations have been loaded, they are merged into a single JS object. The order is such that later defined configuration providers can override the configuration from earlier providers.
After the configuration is loaded and merged, it is validated against the provided schema. This is done using ajv:
confconf
with { freezeConfig: false }
.See Ajv's type coercion rules for more details how the type coercion works.
Confconf uses debug
to provide debug logging. Debug logging can be enabled by setting DEBUG=confconf
env variable.
DEBUG=confconf node app.js
Example of how the logs look like:
confconf is bundled with the following providers:
In addition these are coming available soon:
.env
filesFAQs
A node.js configuration manager
The npm package @confconf/confconf receives a total of 15 weekly downloads. As such, @confconf/confconf popularity was classified as not popular.
We found that @confconf/confconf demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.