import { ArkErrors, type } from "arktype";
import { Duration } from "luxon";
const serverEnv = type({
SESSION_COOKIE_PASSWORD: "string",
AUTH_TYPE: "'local' | 'workos'",
}).and(
type({
AUTH_TYPE: "'local'",
ACCESS_TOKEN_TTL: "string | null = null",
REFRESH_TOKEN_TTL: "string | null = null",
})
.pipe.try((localAuth) => ({
AUTH_TYPE: localAuth.AUTH_TYPE,
ACCESS_TOKEN_TTL:
localAuth.ACCESS_TOKEN_TTL === null
? Duration.fromObject({ hours: 1 })
: Duration.fromISO(localAuth.ACCESS_TOKEN_TTL),
REFRESH_TOKEN_TTL:
localAuth.REFRESH_TOKEN_TTL === null
? Duration.fromObject({ days: 1 })
: Duration.fromISO(localAuth.REFRESH_TOKEN_TTL),
}))
.or({
AUTH_TYPE: "'workos'",
WORKOS_CLIENT_ID: "string",
WORKOS_API_KEY: "string",
WORKOS_REDIRECT_URI: "string.url.parse",
}),
);
import { ArkErrors, type } from "arktype";
import { Duration } from "luxon";
const serverEnv = type({
SESSION_COOKIE_PASSWORD: "string",
AUTH_TYPE: "'local' | 'workos'",
}).and(
type({
AUTH_TYPE: "'local'",
ACCESS_TOKEN_TTL: "string | null = null",
REFRESH_TOKEN_TTL: "string | null = null",
})
.pipe.try((localAuth) => ({
AUTH_TYPE: localAuth.AUTH_TYPE,
ACCESS_TOKEN_TTL:
localAuth.ACCESS_TOKEN_TTL === null
? Duration.fromObject({ hours: 1 })
: Duration.fromISO(localAuth.ACCESS_TOKEN_TTL),
REFRESH_TOKEN_TTL:
localAuth.REFRESH_TOKEN_TTL === null
? Duration.fromObject({ days: 1 })
: Duration.fromISO(localAuth.REFRESH_TOKEN_TTL),
}))
.or({
AUTH_TYPE: "'workos'",
WORKOS_CLIENT_ID: "string",
WORKOS_API_KEY: "string",
WORKOS_REDIRECT_URI: "string.url.parse",
}),
);