Skip to content

Commit

Permalink
add: getEnvKeyOrThrow & dotenv
Browse files Browse the repository at this point in the history
  • Loading branch information
Mithreum committed Jan 24, 2024
1 parent 2893bcb commit 6dd865c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 0 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ Installation with `npm`:

```bash
npm install emmet-sdk-v2
npm install @types/emmet-sdk-v2 --save-dev
```

Installation with `yarn`:

```bash
yarn add emmet-sdk-v2
yarn add @types/emmet-sdk-v2 -D
```

## Library contents
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "emmet-sdk-v2",
"version": "2.0.2",
"version": "2.0.3",
"description": "An SDK for Emmet.Finance Bridge",
"main": "index.js",
"types": "./emmet-sdk-v2/index.d.ts",
Expand All @@ -18,6 +18,7 @@
"author": "[email protected]",
"license": "ISC",
"dependencies": {
"dotenv": "^16.4.0",
"viem": "^2.4.0"
},
"devDependencies": {
Expand Down
14 changes: 13 additions & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
export * from './address';
export * from './viem';
export * from './viem';

export function getEnvKeyOrThrow(key: string): string {
try {
require('dotenv').config();
const value = process.env[key];
if (value) return value;

} catch (error:{message:string}|any) {
throw new Error(`emmet-sdk-v2 getEnvKeyOrThrow Error: ${error.message}`);
}
throw new Error(`${key} is missing in the .env.`);
}

0 comments on commit 6dd865c

Please sign in to comment.