Skip to content

What This Adds In Cloud Code

  • Secure secret and config retrieval without hardcoding.
  • Shared values across jobs, routes, callbacks, and functions.
  • Runtime cache-backed lookups for repeated access.

Quick Start

js
const apiKey = Nimbu.Site.env.get('PARTNER_API_KEY');
const hasWebhookSecret = Nimbu.Site.env.has('WEBHOOK_SECRET');

API

Nimbu.Site.env (global helper):

FunctionParamsReturnsNotes
get(name)name: stringstring | nullReturns variable value or null.
has(name)name: stringbooleanTrue if key exists.
keys()nonestring[]Available variable names.

require('site_variables') module export:

FunctionParamsReturns
variable(name)stringstring | null
has_variable(name)stringboolean
all_variable_names()nonestring[]

Practical Example

js
const HTTP = require('http');

const token = Nimbu.Site.env.get('CRM_TOKEN');
if (!token) throw new Error('CRM_TOKEN missing');

HTTP.post(
  'https://crm.example.com/api/subscribers',
  JSON.stringify({ email: request.params.email }),
  {
    Authorization: `Bearer ${token}`,
    'Content-Type': 'application/json'
  }
);

Failure Modes & Gotchas

  • Missing keys return null; handle explicitly.
  • Do not log secret values.