mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
* refactor: unify backend and frontend servers * refactor: correct paths for openapi & drizzle * refactor: move api-client to client * fix: drizzle paths * chore: fix linting issues * fix: form reset issue
24 lines
615 B
TypeScript
24 lines
615 B
TypeScript
import { type } from "arktype";
|
|
import "dotenv/config";
|
|
|
|
const envSchema = type({
|
|
NODE_ENV: type.enumerated("development", "production", "test").default("development"),
|
|
SESSION_SECRET: "string?",
|
|
}).pipe((s) => ({
|
|
__prod__: s.NODE_ENV === "production",
|
|
environment: s.NODE_ENV,
|
|
sessionSecret: s.SESSION_SECRET || "change-me-in-production-please",
|
|
}));
|
|
|
|
const parseConfig = (env: unknown) => {
|
|
const result = envSchema(env);
|
|
|
|
if (result instanceof type.errors) {
|
|
throw new Error(`Invalid environment variables: ${result.toString()}`);
|
|
}
|
|
|
|
return result;
|
|
};
|
|
|
|
export const config = parseConfig(process.env);
|