benjivers/notes Public Public: anyone can read this; nobody can change it.

Files main
40 lines · 2.2 KB · ~633 tok Raw History
1
/**
2
 * What the forge told this process, read once and named once. Every other
3
 * module takes these from here, so nothing else spells an environment
4
 * variable — and running the app by hand needs none of them.
5
 */
6
7
import pkg from "../package.json";
8
9
export const title: string = pkg.name;
10
/** The app's own version (package.json): what `/healthz` and `/openapi.json` say. */
11
export const version: string = pkg.version ?? "0.0.0";
12
/** When this process started, for `/healthz`'s uptime. */
13
export const startedAt: number = Date.now();
14
export const description: string = pkg.description || "A new app on the forge.";
15
export const dataDir: string = process.env.FORGE_APP_DATA ?? "./data";
16
export const env: string = process.env.FORGE_APP_ENV ?? "local";
17
export const commit: string = (process.env.FORGE_APP_COMMIT ?? "").slice(0, 7);
18
/** Where this process runs, for a person: `production`, `preview of pull #3`, `local`. */
19
export const where: string =
20
  env === "preview"
21
    ? `preview of pull #${process.env.FORGE_APP_PULL ?? "?"}`
22
    : env;
23
/** The exact command that opens this environment's terminal. Print it verbatim, never a guess. */
24
export const ssh: string | undefined = process.env.FORGE_APP_SSH;
25
/** The address the forge serves us at — what a browser sees, never the socket's. */
26
export const publicOrigin: string = new URL(
27
  process.env.FORGE_APP_URL ?? "http://localhost",
28
).origin;
29
/** The forge that runs us. Its own well-known files (security.txt) speak for its apps. */
30
export const forgeUrl: string | undefined = process.env.FORGE_URL;
31
/** The key the forge signs identities with (`who.ts`). Unset, everyone is anonymous. */
32
export const identityKey: string = process.env.FORGE_APP_IDENTITY_KEY ?? "";
33
/** The forge's JSON API, for shared folders (`src/sync.ts`). */
34
export const forgeApi: string | undefined =
35
  process.env.FORGE_API_URL ?? (forgeUrl === undefined ? undefined : `${forgeUrl.replace(/\/+$/, "")}/api/v1`);
36
/**
37
 * A forge token that may write the repositories shared folders keep their
38
 * notes in (Settings → App → Environment). Unset, there are no shared folders.
39
 */
40
export const repoToken: string | undefined = process.env.NOTES_REPO_TOKEN?.trim() || undefined;
↑↓ navigate ↵ open esc close
↑↓ navigate ↵ open esc close

Keyboard shortcuts