Skip to content

Configuration reference

postgresdk reads a postgresdk.config.ts that default-exports a Config object. Use postgresdk init to scaffold one.

import type { Config } from "postgresdk";
export default {
connectionString: process.env.DATABASE_URL!,
outDir: { client: "./api/client", server: "./api/server" },
} satisfies Config;

The default export of your postgresdk.config.ts. Only connectionString is required.

OptionTypeDefaultDescription
connectionStringstringPostgres connection string used to introspect the schema (e.g. "postgres://user:pass@host:5432/db"). Read it from an env var in real configs.
schema?string"public"Postgres schema to introspect.
outDir?string | { client: string; server: string }{ client: "./api/client", server: "./api/server" }Where generated code is written. A single string is used for both server and client (the client SDK lands in an sdk/ subdirectory); an object sets each separately.
delete?DeleteConfigSoft/hard delete behavior.
numericMode?"string" | "number" | "auto""auto"How numeric columns are typed. "auto" maps int2/int4number and int8/numericstring (to avoid precision loss).
includeMethodsDepth?number2How deep to generate eager-loading include helper methods.
skipJunctionTables?booleantrueSkip junction (M:N) tables when generating include methods.
serverFramework?"hono" | "express" | "fastify""hono"Server framework for the generated routes. Only "hono" is implemented today; "express"/"fastify" are reserved.
apiPathPrefix?string"/v1"Path prefix for the generated table routes.
maxLimit?number1000Maximum allowed value for the limit parameter in list operations. Set to 0 to disable the cap.
auth?AuthConfigInputAPI authentication. Omit for no auth. Accepts the API-key shorthand or a full AuthConfig.
pullToken?stringToken protecting the /_psdk/* SDK-distribution endpoints. Use the "env:VAR_NAME" form. If unset, those endpoints are public.
pull?PullConfigPull configuration for client repos that consume a generated SDK over HTTP.
useJsExtensions?booleanfalseEmit .js import extensions in generated server code (needed for Vercel Edge).
useJsExtensionsClient?booleanfalseEmit .js import extensions in generated client SDK code (for certain bundlers/runtimes).
clean?booleantrueDelete generated files for tables/items no longer present in the schema.
tests?object — see belowGenerated test-suite configuration.
OptionTypeDefaultDescription
generate?booleanfalseGenerate test files.
output?string"./api/tests"Output directory for generated tests.
framework?"vitest" | "jest" | "bun""vitest"Test framework for the generated tests.

Shape of Config.delete.

OptionTypeDefaultDescription
softDeleteColumn?stringColumn name for soft deletes (e.g. "deleted_at"). Absence means hard deletes only.
exposeHardDelete?booleantrueWhether to also expose hardDelete when soft delete is configured.
softDeleteColumnOverrides?Record<string, string | null>Per-table overrides. Use null to disable soft delete for a specific table.

Full shape of Config.auth. An API-key shorthand ({ apiKey: "..." }) is also accepted and normalized to this.

OptionTypeDefaultDescription
apiKeyHeader?string"x-api-key"Header to read the API key from.
apiKeys?string[]Accepted API keys. A value may use the "env:MY_KEY_LIST" form to read a comma-separated list from the environment.
jwt?object — see belowJWT (HS256) verification config. Its presence selects the JWT auth strategy.
OptionTypeDefaultDescription
servicesobject — see below
audience?stringWhen set, validates the JWT aud claim.
OptionTypeDefaultDescription
issuerstringIdentifies the calling service. Must match the JWT iss claim.
secretstringSigning secret. MUST use the "env:VAR_NAME" form (e.g. "env:JWT_SECRET"). SECURITY: never inline process.env.X or a literal secret here. The generator rewrites "env:JWT_SECRET" to process.env.JWT_SECRET in the generated code.

Shape of Config.pull, used by client repos that pull a generated SDK over HTTP.

OptionTypeDefaultDescription
fromstringAPI URL to pull the SDK from.
output?string"./src/sdk"Output directory for the pulled SDK.
pullToken?stringAuth token for the /_psdk/* endpoints. Use the "env:VAR_NAME" form.