doorman/packages/server/src/util/EnvConfigUtil.ts
Martin Dimitrov 4c6399f0c3
All checks were successful
Build and push image for doorman / docker (push) Successful in 55s
Build and push image for doorman / deploy-portainer (push) Successful in 32s
change to env var config
2024-02-27 21:31:32 -08:00

24 lines
726 B
TypeScript

import { IAuthMode } from "../types/IAuthMode";
import { IDoorConfig } from "../types/IDoorConfig";
const doorToEnv = (door: string): string => {
return door.toUpperCase().replaceAll(' ', '_').replaceAll('-', '_');
};
export const getAuthModes = (door: string): IAuthMode[] => {
const config = getDoorSettingString(door, IDoorConfig.AUTH_MODES);
if (config) {
return JSON.parse(config);
}
return [];
};
export const getDoorSettingString = (door: string, setting: IDoorConfig): string | undefined => {
return Bun.env[`${setting}_${doorToEnv(door)}`];
};
export const getDoorSettingNumber = (door: string, setting: IDoorConfig): number => {
return parseInt(getDoorSettingString(door, setting) || "0");
};