Co-authored-by: Claude Fable 5.1 <[email protected]> Co-authored-by: Julius Marminge <[email protected]> Co-authored-by: Julius Marminge <[email protected]>
56 lines
2.2 KiB
TypeScript
56 lines
2.2 KiB
TypeScript
import * as Config from "effect/Config";
|
|
import * as Context from "effect/Context";
|
|
import * as Effect from "effect/Effect";
|
|
import * as Layer from "effect/Layer";
|
|
import * as Redacted from "effect/Redacted";
|
|
import * as Schema from "effect/Schema";
|
|
|
|
export const ApnsEnvironment = Schema.Literals(["sandbox", "production"]);
|
|
export type ApnsEnvironment = typeof ApnsEnvironment.Type;
|
|
|
|
export const ManagedEndpointCleanupMode = Schema.Literals(["off", "dry-run", "enabled"]);
|
|
export type ManagedEndpointCleanupMode = typeof ManagedEndpointCleanupMode.Type;
|
|
const decodeManagedEndpointCleanupMode = Schema.decodeUnknownEffect(ManagedEndpointCleanupMode);
|
|
|
|
export const managedEndpointCleanupModeConfig = Config.String("RELAY_TUNNEL_CLEANUP_MODE").pipe(
|
|
Config.withDefault("off"),
|
|
Config.map((value) => value.trim() || "off"),
|
|
Config.mapEffect((value) =>
|
|
decodeManagedEndpointCleanupMode(value).pipe(
|
|
Effect.mapError((error) => new Config.ConfigError(error)),
|
|
),
|
|
),
|
|
);
|
|
|
|
export interface ApnsCredentials {
|
|
readonly teamId: string;
|
|
readonly keyId: string;
|
|
readonly privateKey: Redacted.Redacted<string>;
|
|
readonly bundleId: string;
|
|
readonly environment: ApnsEnvironment;
|
|
}
|
|
|
|
export class RelayConfiguration extends Context.Service<
|
|
RelayConfiguration,
|
|
{
|
|
readonly relayIssuer: string;
|
|
readonly apns: ApnsCredentials | null;
|
|
readonly fcmServiceAccount?: Redacted.Redacted<string>;
|
|
readonly clerkSecretKey: Redacted.Redacted<string>;
|
|
readonly clerkPublishableKey: string;
|
|
readonly clerkJwtAudience: string;
|
|
readonly apnsDeliveryJobSigningSecret: Redacted.Redacted<string>;
|
|
readonly cloudMintPrivateKey: Redacted.Redacted<string>;
|
|
readonly cloudMintPublicKey: string;
|
|
readonly managedEndpointBaseDomain: string | undefined;
|
|
readonly managedEndpointNamespace: string | undefined;
|
|
readonly managedEndpointCleanupMode?: ManagedEndpointCleanupMode;
|
|
}
|
|
>()("t3code-relay/Config/RelayConfiguration") {}
|
|
|
|
export const make = (configuration: RelayConfiguration["Service"]) =>
|
|
RelayConfiguration.of(configuration);
|
|
|
|
export const layer = (configuration: RelayConfiguration["Service"]) =>
|
|
Layer.succeed(RelayConfiguration, make(configuration));
|