Parse backend environment, expose more settings
This commit is contained in:
33
packages/backend/src/config.ts
Normal file
33
packages/backend/src/config.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { pipe, Schema } from "effect";
|
||||
import { constant } from "effect/Function";
|
||||
|
||||
/* NOTE I know "effect/Config" exists, but I also don't care. This works for me. */
|
||||
|
||||
export const Config = Schema.Struct({
|
||||
CLIENT_ID: Schema.UUID,
|
||||
CLIENT_SECRET: pipe(
|
||||
Schema.String,
|
||||
Schema.Redacted,
|
||||
),
|
||||
DB_PATH: pipe(
|
||||
Schema.String,
|
||||
Schema.optional,
|
||||
),
|
||||
NODE_ENV: pipe(
|
||||
Schema.Literal("development", "production"),
|
||||
Schema.optionalWith({ default: constant("development" as const) }),
|
||||
),
|
||||
PORT: pipe(
|
||||
Schema.NumberFromString,
|
||||
Schema.optionalWith({ default: constant(3000) }),
|
||||
),
|
||||
TENANT_ID: Schema.UUID,
|
||||
TENANT_SUBDOMAIN: Schema.String,
|
||||
});
|
||||
|
||||
export type Config = typeof Config.Type;
|
||||
|
||||
export const config = pipe(
|
||||
process.env,
|
||||
Schema.decodeUnknownSync(Config),
|
||||
);
|
||||
Reference in New Issue
Block a user