Skip to content

Commit

Permalink
Throw error if user hasn't set env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
agam778 committed Mar 2, 2022
1 parent 0886a2c commit 09e9451
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ if (fs.existsSync(".env")) {
dotenv.config();
}

if (!process.env.TELEGRAM_BOT_TOKEN || !process.env.TELEGRAM_CHAT_ID) {
throw new Error(
"Please set the TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID environment variables"
);
}

const app = express();
const bot = new Telegraf(process.env.TELEGRAM_BOT_TOKEN);

const TELEGRAM_CHAT_ID = process.env.TELEGRAM_CHAT_ID;

const PORT = process.env.PORT || 5000;

app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());

Expand Down

0 comments on commit 09e9451

Please sign in to comment.