From 04f4b72b8759c3feab764ea4e5154f6f73883d83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Gro=C3=9F?= Date: Wed, 24 May 2023 16:44:15 +0200 Subject: [PATCH] Move config to .env --- package-lock.json | 16 +++++++++++++++- package.json | 3 ++- src/index.js | 5 +++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index b242552..d348d5f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,8 @@ "license": "ISC", "dependencies": { "axios": "^1.4.0", - "discord-webhook-node": "^1.1.8" + "discord-webhook-node": "^1.1.8", + "dotenv": "^16.0.3" } }, "node_modules/asynckit": { @@ -69,6 +70,14 @@ "node": ">= 6" } }, + "node_modules/dotenv": { + "version": "16.0.3", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", + "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==", + "engines": { + "node": ">=12" + } + }, "node_modules/follow-redirects": { "version": "1.15.2", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", @@ -214,6 +223,11 @@ } } }, + "dotenv": { + "version": "16.0.3", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", + "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==" + }, "follow-redirects": { "version": "1.15.2", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", diff --git a/package.json b/package.json index fc9f8a8..db164d1 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "license": "ISC", "dependencies": { "axios": "^1.4.0", - "discord-webhook-node": "^1.1.8" + "discord-webhook-node": "^1.1.8", + "dotenv": "^16.0.3" } } diff --git a/src/index.js b/src/index.js index 7b60c26..5aae7e4 100644 --- a/src/index.js +++ b/src/index.js @@ -1,12 +1,13 @@ +require('dotenv').config() const axios = require('axios'); const { STATUS_CODES } = require('http'); const { Webhook, MessageBuilder } = require('discord-webhook-node'); // API endpoint URL to ping -const apiUrl = 'https://toho.mnz.gg/api/v1/ping'; +const apiUrl = process.env.API_URL; // Discord webhook URL to send messages -const webhookUrl = 'https://discord.com/api/webhooks/1110880167536099328/GE6T1D81sGFvG08EOMdAo3sL1WIizowu-t78An0L9fcbgL6BAkoH0Lu74rtilS1KJUqO'; +const webhookUrl = process.env.WEBHOOK; // Create a new Discord webhook instance const webhook = new Webhook(webhookUrl);