feat: modular domain driven boilerplate
This commit is contained in:
19
platform/config/service.ts
Normal file
19
platform/config/service.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { getDotEnvVariable } from "./dotenv.ts";
|
||||
|
||||
export const SERVICE_ENV = ["testing", "local", "stg", "demo", "prod"] as const;
|
||||
|
||||
/**
|
||||
* TODO ...
|
||||
*/
|
||||
export function getServiceEnvironment(): ServiceEnvironment {
|
||||
const value = getDotEnvVariable("SERVICE_ENV");
|
||||
if (value === undefined) {
|
||||
return "local";
|
||||
}
|
||||
if ((SERVICE_ENV as unknown as string[]).includes(value) === false) {
|
||||
throw new Error(`Config Exception: Invalid env ${value} provided`);
|
||||
}
|
||||
return value as ServiceEnvironment;
|
||||
}
|
||||
|
||||
export type ServiceEnvironment = (typeof SERVICE_ENV)[number];
|
||||
Reference in New Issue
Block a user