47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
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({
|
|
DB_PATH: pipe(
|
|
Schema.String,
|
|
Schema.optionalWith({ default: constant("db.sqlite3") }),
|
|
),
|
|
HOSTNAME: Schema.String,
|
|
NODE_ENV: pipe(
|
|
Schema.Literal("development", "production"),
|
|
Schema.optionalWith({ default: constant("development" as const) }),
|
|
),
|
|
PORT: pipe(
|
|
Schema.NumberFromString,
|
|
Schema.optionalWith({ default: constant(3000) }),
|
|
),
|
|
OAUTH_CLIENT_ID: Schema.String,
|
|
OAUTH_CLIENT_SECRET: pipe(
|
|
Schema.String,
|
|
Schema.Redacted,
|
|
),
|
|
OAUTH_AUTHORIZATION_ENDPOINT: Schema.String,
|
|
OAUTH_TOKEN_ENDPOINT: Schema.String,
|
|
OAUTH_USER_ID_CLAIM: pipe(
|
|
Schema.String,
|
|
Schema.optionalWith({ default: constant("sub") }),
|
|
),
|
|
OAUTH_DISPLAY_NAME_CLAIM: pipe(
|
|
Schema.String,
|
|
Schema.optionalWith({ default: constant("display_name") }),
|
|
),
|
|
OAUTH_AVATAR_URL_CLAIM: pipe(
|
|
Schema.String,
|
|
Schema.optionalWith({ default: constant("picture") }),
|
|
),
|
|
});
|
|
|
|
export type Config = typeof Config.Type;
|
|
|
|
export const config = pipe(
|
|
process.env,
|
|
Schema.decodeUnknownSync(Config),
|
|
);
|