mirror of
https://github.com/fdundjer/solana-sniper-bot.git
synced 2025-11-18 18:51:10 +10:00
Add logic to use env variables
This commit is contained in:
@ -1,3 +1,7 @@
|
||||
import { Logger } from "pino";
|
||||
import dotenv from 'dotenv';
|
||||
dotenv.config();
|
||||
|
||||
/**
|
||||
* Runs the function `fn`
|
||||
* and retries automatically if it fails.
|
||||
@ -23,3 +27,12 @@ export const retry = async <T>(
|
||||
};
|
||||
|
||||
export const sleep = (ms = 0) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
|
||||
export const retrieveEnvVariable = (variableName: string, logger: Logger) => {
|
||||
const variable = process.env[variableName] || '';
|
||||
if (!variable) {
|
||||
logger.error(`${variableName} is not set`);
|
||||
process.exit(1);
|
||||
}
|
||||
return variable;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user