
Product
Reachability for Ruby Now in Beta
Reachability analysis for Ruby is now in beta, helping teams identify which vulnerabilities are truly exploitable in their applications.
@clipboard-health/config
Advanced tools
Type-safe static configuration management: a pure function to resolve, validate against a Zod schema, and freeze configuration values.
Type-safe static configuration management: a pure function to resolve, validate against a Zod schema, and freeze configuration values.
Configuration values resolve in order from highest precedence to lowest:
{ myApi: { port: 3000 } } configuration resolves to MY_API_PORT.Supported configuration value types:
To override arrays with environment variables, use stringified JSON arrays, e.g. ["a","b"].
IMPORTANT: To avoid runtime errors:
z.coerce Zod types for those you plan to override.
Note that z.coerce.boolean() coerces any truthy value to true. To restrict to "true" | "false", use the booleanString schema from @clipboard-health/contract-core.ReadonlyDeep<SchemaT>, but the library returns a
Readonly<SchemaT> because the former prevents clients from passing configuration values to
functions that don't explicitly accept readonly types.npm install @clipboard-health/config
import { ok } from "node:assert/strict";
import { createConfig } from "@clipboard-health/config";
import { z } from "zod";
const allowed = ["local", "development", "production"] as const;
type Allowed = (typeof allowed)[number];
function createEnvironmentConfig(current: Allowed) {
return createConfig({
config: {
baseUrl: {
defaultValue: "http://localhost:3000",
description: "Base URL for API requests",
overrides: {
development: "https://dev.example.com",
production: "https://api.example.com",
},
},
database: {
port: {
defaultValue: 5432,
description: "Database port",
},
},
},
environment: { allowed, current },
schema: z.object({
baseUrl: z.string().url(),
database: z.object({
// Use `z.coerce` to override with environment variables.
port: z.coerce.number().min(1024).max(65_535),
}),
}),
});
}
{
// Uses default values.
const config = createEnvironmentConfig("local");
ok(config.baseUrl === "http://localhost:3000");
ok(config.database.port === 5432);
}
{
// Uses baseUrl environment override.
const config = createEnvironmentConfig("development");
ok(config.baseUrl === "https://dev.example.com");
ok(config.database.port === 5432);
}
// Uses environment variable overrides.
const original = { ...process.env };
try {
process.env["BASE_URL"] = "https://staging.example.com";
process.env["DATABASE_PORT"] = "54320";
const config = createEnvironmentConfig("local");
ok(config.baseUrl === "https://staging.example.com");
ok(config.database.port === 54_320);
} finally {
process.env = { ...original };
}
See package.json scripts for a list of commands.
FAQs
Type-safe static configuration management: a pure function to resolve, validate against a Zod schema, and freeze configuration values.
We found that @clipboard-health/config demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers 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
Reachability analysis for Ruby is now in beta, helping teams identify which vulnerabilities are truly exploitable in their applications.

Research
/Security News
Malicious npm packages use Adspect cloaking and fake CAPTCHAs to fingerprint visitors and redirect victims to crypto-themed scam sites.

Security News
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.