wispfnDocs
Function SDK

Read the project's variables and secrets.

import { config } from 'wisp';
from wisp import config

Variables and secrets are read the same way. See Variables and secrets.

#config.get(name, fallback?)

Returns the value as a string, or fallback (default undefined / None) when it isn't set.

const base = config.get('API_BASE', 'https://api.example.com');

#config.require(name)

Returns the value, or throws a WispError that names the missing setting.

key = config.require("OPENAI_API_KEY")

Use get and return your own error when you want a friendlier response:

const key = config.get('OPENAI_API_KEY');
if (!key) return { status: 500, body: { error: 'OPENAI_API_KEY is not set' } };

#config.has(name)

true when the setting exists.

#config.names()

The names of all variables and secrets of the project.