24 lines
726 B
TypeScript
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");
|
|
}; |