mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-24 20:55:04 +02:00
bootstrapped
This commit is contained in:
parent
b7c1716fa7
commit
d2e35b4a1f
24 changed files with 15511 additions and 5203 deletions
27
server/environment.ts
Normal file
27
server/environment.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import { z } from "zod";
|
||||
import { fromError } from "zod-validation-error";
|
||||
|
||||
const environmentSchema = z.object({
|
||||
ENVIRONMENT: z.string(),
|
||||
LOG_LEVEL: z.string(),
|
||||
SAVE_LOGS: z.string().transform((val) => val === "true"),
|
||||
PORT: z.string(),
|
||||
CONFIG_PATH: z.string(),
|
||||
});
|
||||
|
||||
const environment = {
|
||||
ENVIRONMENT: (process.env.ENVIRONMENT as string) || "dev",
|
||||
LOG_LEVEL: (process.env.LOG_LEVEL as string) || "debug",
|
||||
SAVE_LOGS: (process.env.SAVE_LOGS as string) || "false",
|
||||
PORT: (process.env.PORT as string) || "3000",
|
||||
CONFIG_PATH: process.env.CONFIG_PATH as string,
|
||||
};
|
||||
|
||||
const parsedConfig = environmentSchema.safeParse(environment);
|
||||
|
||||
if (!parsedConfig.success) {
|
||||
const errors = fromError(parsedConfig.error);
|
||||
throw new Error(`Invalid environment configuration: ${errors}`);
|
||||
}
|
||||
|
||||
export default parsedConfig.data;
|
Loading…
Add table
Add a link
Reference in a new issue