Add default to getEnvVar and better typing
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@mifi/services-common",
|
||||
"version": "1.0.9",
|
||||
"version": "1.0.11",
|
||||
"author": "mifi (Mike Fitzpatrick)",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export const getEnvVar = (key: string) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export const getEnvVar = <T = any>(key: string, defaultValue: T): T => {
|
||||
const val = process.env[key];
|
||||
if (!val) return undefined;
|
||||
if (!val) return defaultValue as T;
|
||||
else return JSON.parse(val);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user