lobster-kit
v0.0.3
Published
Shared TypeScript utilities for Cloud Lobsters projects
Maintainers
Readme
lobster-kit
Shared TypeScript utilities for Cloud Lobsters projects.
Install
pnpm add lobster-kit valibotIf you use the Postgres variable source, also install pg:
pnpm add pgModules
lobster-kit/variables— typed async configuration registry for env, database, and custom sources.lobster-kit/docs— local SQLite/FTS documentation indexer and search CLI.
Variables registry
lobster-kit/variables provides a typed, async, source-pluggable
configuration registry. It resolves values from environment variables,
database rows, or custom key/value sources with Valibot validation,
in-memory caching, optional writes, and boot-time checks for required
values.
import * as v from 'valibot';
import {
create_registry,
env_source,
map_cache,
} from 'lobster-kit/variables';
const variables = create_registry({
sources: {
env: env_source(process.env),
},
resolve_order: ['env'],
cache: map_cache({ ttl_ms: 300_000 }),
variables: {
'app.port': {
from: { env: 'APP_PORT' },
schema: v.number(),
default: 3000,
public: true,
},
'vendor.api_key': {
from: { env: 'VENDOR_API_KEY' },
schema: v.pipe(v.string(), v.minLength(32)),
secret: true,
},
},
});
const port = await variables.get('app.port');
await variables.validate_boot();Secrets marked with secret: true are redacted in validation errors.
Only variables marked public: true are returned by get_public().
Development
pnpm install
pnpm run check
pnpm run test
pnpm run buildRelease
This package uses Changesets.
pnpm changeset
pnpm run version
pnpm run release