npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@askdb/config

v1.0.0-beta.11

Published

AskDB configuration helpers: Prisma-style env() and askdb.config file discovery for first-party apps.

Readme

@askdb/config

Prisma-style helpers for AskDB: env(), defineConfig(), plus discovery and loading of askdb.config.* / .config/askdb.* files used by first-party apps (askdb CLI, @askdb/http-api, @askdb/studio).

@askdb/config is the single package that reads process.env directly (during dotenv load, while askdb.config.* evaluates, and for a tiny bootstrap-time overlay allowlist). All other packages obtain configuration through getAskDbRuntimeConfig().

Install

pnpm add @askdb/config

Config file discovery

AskDB searches the working directory (cwd, usually process.cwd()) in this order:

  1. askdb.config.<ext> — extension precedence: tsmtsctsjsmjscjs (first existing file wins).
  2. .config/askdb.<ext> — same extension precedence.

This mirrors the layout described in Prisma's config reference, but uses .config/askdb.* so it does not collide with Prisma's own .config/prisma.* files.

Example askdb.config.ts

import "dotenv/config";
import { defineConfig, env, type AskDbConfig } from "@askdb/config";

export default defineConfig({
  ai: {
    provider: "openai",
    providerConfig: {
      openai: {
        apiKey: env("MY_OPENAI_API_KEY"),
        model: env("MY_CHAT_MODEL"),
      },
    },
  },
  database: {
    provider: "postgres",
    providerConfig: { postgres: { databaseUrl: env("MY_DATABASE_URL") } },
  },
  introspection: {
    provider: "postgres",
    providerConfig: { postgres: {} },
    outputDir: env("MY_INTROSPECT_OUTPUT_DIR"),
  },
  rag: {
    embedder: "mock",
    embedderConfig: {},
    store: "memory",
    storeConfig: { memory: {} },
  },
} satisfies AskDbConfig);

Your .env can use friendly names (MY_OPENAI_API_KEY, …). defineConfig runs flattenAskDbConfig, which maps the nested object onto the canonical environment variable names used in the runtime flat map (and in aiEnv for @askdb/ai). Unset optional fields get defaults inside flattenAskDbConfig (chat model, introspection output dir, database URL fallbacks, RAG embedding dimensions, file-store base path, pgvector index strategy, etc. — see packages/config/src/defaults.ts).

Architectural rule — @askdb/config is the sole process.env reader

Only @askdb/config reads process.env directly. All AskDB library packages obtain their configuration through a single typed gateway:

import { getAskDbRuntimeConfig } from "@askdb/config";

const config = getAskDbRuntimeConfig();
const apiKey = opts.apiKey ?? config.rag.embedder.apiKey;
const level = config.logging.level;
// For @askdb/ai registry methods that accept an env-map argument:
const model = await aiRegistry.createLanguageModelFromEnv(config.ai.aiEnv, { ... });

Rules:

  • Library packages (@askdb/rag, @askdb/enrich, …) must call getAskDbRuntimeConfig() and use the returned typed fields. They must not call env(), requiredEnv(), or access process.env directly.
  • env(name) is only for use inside askdb.config.* files authored by end users — it maps friendly .env names onto values that become part of the structured config and flat map.
  • First-party app entry points call bootstrapAskDbEnv() at start-up. That loads dotenv, evaluates askdb.config.*, and installs an in-memory runtime snapshot (structured config + flat map + derived aiEnv). It does not copy AskDB settings into process.env.

Migration from legacy flat config

export default { OPENAI_API_KEY: "…" } is no longer supported. Use nested defineConfig({ ... satisfies AskDbConfig }) and export default defineConfig({ … }).

API

  • getAskDbRuntimeConfig()primary API for library packages. Returns a typed AskDbRuntimeConfig from the bootstrapped snapshot (structured, flat-derived fields, and ai.aiEnv for @askdb/core).
  • env(name) / requiredEnv(name) — read process.env while authoring askdb.config.* only.
  • defineConfig(config) — returns an AskDbEnvProjection with config (structured) and entries (flattened canonical map).
  • flattenAskDbConfig(config) — nested config → flat canonical map (applies defaults for optional values).
  • bootstrapAskDbEnv(options?) / bootstrapAskDbRuntime — load dotenv, load config, install the runtime snapshot.
  • loadAskDbConfigProjection(cwd) / loadAskDbConfigProjectionSync(cwd) — load projection without installing the singleton (advanced / tests).
  • discoverAskDbConfigPath(cwd) — returns the resolved config path, if any.
  • mergeAskDbFlatIntoEnvMap(base, flat) — merge AskDB flat entries into an env map for child processes (does not read process.env itself). Use getAskDbRuntimeConfig().flat as flat after bootstrap.
  • setAskDbRuntimeForTests / resetAskDbRuntimeForTests — test helpers for the runtime snapshot.

License

Apache-2.0 © Yahya Gilany. See LICENSE and NOTICE.