mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-24 20:55:04 +02:00
simplify installer and remove parsing from read config
This commit is contained in:
parent
9f38ad9b4d
commit
ead5df0a8c
9 changed files with 51 additions and 70 deletions
|
@ -5,6 +5,7 @@ import { SupporterKey, supporterKey } from "@server/db";
|
|||
import { eq } from "drizzle-orm";
|
||||
import { license } from "@server/license/license";
|
||||
import { configSchema, readConfigFile } from "./readConfigFile";
|
||||
import { fromError } from "zod-validation-error";
|
||||
|
||||
export class Config {
|
||||
private rawConfig!: z.infer<typeof configSchema>;
|
||||
|
@ -20,7 +21,29 @@ export class Config {
|
|||
}
|
||||
|
||||
public load() {
|
||||
const parsedConfig = readConfigFile();
|
||||
const environment = readConfigFile();
|
||||
|
||||
const {
|
||||
data: parsedConfig,
|
||||
success,
|
||||
error
|
||||
} = configSchema.safeParse(environment);
|
||||
|
||||
if (!success) {
|
||||
const errors = fromError(error);
|
||||
throw new Error(`Invalid configuration file: ${errors}`);
|
||||
}
|
||||
|
||||
if (process.env.APP_BASE_DOMAIN) {
|
||||
console.log(
|
||||
"You're using deprecated environment variables. Transition to the configuration file. https://docs.fossorial.io/"
|
||||
);
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
if (parsedConfig.users) {
|
||||
console.log("You're admin credentials are still in the config file. This method of setting admin credentials is deprecated. It is recommended to remove them from the config file.");
|
||||
}
|
||||
|
||||
process.env.APP_VERSION = APP_VERSION;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue