Skip to content

GetSecret

Source: src/Fly/GetSecret.ts

Fetch one Fly.io App secret. The App and name are fixed by GetSecret(secret). Calls take no app_name.

Bind the client in init. Call it from fetch or an Action body. Provide GetSecretHttp.

Fly only returns plaintext from a Machine in the same App. From a deploy-time Action you get metadata (name, digest, timestamps).

export default class Api extends Fly.Service<Api>()(
"Api",
{ app: Site, main: import.meta.url, port: 3000 },
Effect.gen(function* () {
const get = yield* Fly.GetSecret(ApiToken);
return {
fetch: Effect.gen(function* () {
const got = yield* get().pipe(Effect.orDie);
return HttpServerResponse.json({ name: got.name });
}),
};
}).pipe(Effect.provide(Fly.GetSecretHttp)),
) {}