Files
outline/server/presenters/env.ts
Apoorv Mishra 34e8a64b50 Share env vars client-side using @Public decorator (#6627)
* fix: public env vars using decorator

* fix: relocate

* fix: use env.public

* fix: register public env vars across plugins

* fix: test

* fix: tsc

* fix: mark remaining ones as public

* fix: move oidc ones to plugin

* fix: prevent overwrite

* fix: review
2024-03-09 14:48:59 +05:30

23 lines
679 B
TypeScript

import { IntegrationType, PublicEnv } from "@shared/types";
import { Environment } from "@server/env";
import { Integration } from "@server/models";
// Note: This entire object is stringified in the HTML exposed to the client
// do not add anything here that should be a secret or password
export default function present(
env: Environment,
options: {
analytics?: Integration<IntegrationType.Analytics> | null;
rootShareId?: string | null;
} = {}
): PublicEnv {
return {
ROOT_SHARE_ID: options.rootShareId || undefined,
analytics: {
service: options.analytics?.service,
settings: options.analytics?.settings,
},
...env.public,
};
}