Loading...
Loading...
Compare original and translation side by side
secret(name)import { secret } from "encore.dev/config";
// Package-level declaration
const stripeKey = secret("StripeSecretKey");
// Read inside a handler
async function chargeCustomer() {
const key = stripeKey(); // <-- function call returns the value
const stripe = new Stripe(key);
// ...
}secret(name)import { secret } from "encore.dev/config";
// Package-level declaration
const stripeKey = secret("StripeSecretKey");
// Read inside a handler
async function chargeCustomer() {
const key = stripeKey(); // <-- function call returns the value
const stripe = new Stripe(key);
// ...
}undefinedundefined
Environment types: `production` (alias `prod`), `development` (alias `dev`), `preview` (alias `pr`), `local`.
环境类型:`production`(别名 `prod`)、`development`(别名 `dev`)、`preview`(别名 `pr`)、`local`。encore secret set.secrets.local.cueStripeSecretKey: "sk_test_local_..."
GitHubAPIToken: "ghp_local_..."encore secret set.secrets.local.cueStripeSecretKey: "sk_test_local_..."
GitHubAPIToken: "ghp_local_..."// HTTP headers
const githubToken = secret("GitHubAPIToken");
const resp = await fetch("https://api.github.com/user", {
headers: { Authorization: `token ${githubToken()}` },
});
// Webhook signature verification
const stripeWebhookSecret = secret("StripeWebhookSecret");
stripe.webhooks.constructEvent(rawBody, sig, stripeWebhookSecret());
// Connecting to a third-party SDK
const openaiKey = secret("OpenAIKey");
const openai = new OpenAI({ apiKey: openaiKey() });// HTTP headers
const githubToken = secret("GitHubAPIToken");
const resp = await fetch("https://api.github.com/user", {
headers: { Authorization: `token ${githubToken()}` },
});
// Webhook signature verification
const stripeWebhookSecret = secret("StripeWebhookSecret");
stripe.webhooks.constructEvent(rawBody, sig, stripeWebhookSecret());
// Connecting to a third-party SDK
const openaiKey = secret("OpenAIKey");
const openai = new OpenAI({ apiKey: openaiKey() });secret(...)stripeKey()stripeKeyencore secret set --type <env>.secrets.local.cueencore-webhooksecret(...)stripeKey()stripeKeyencore secret set --type <env>.secrets.local.cueencore-webhook