From 0cb2ae32e886bf8f3ddd79350452e8592820292c Mon Sep 17 00:00:00 2001 From: Ian Torres Date: Thu, 11 Mar 2021 21:33:42 -0300 Subject: [PATCH 1/3] Dotenv and env example implemented (Closes #6). --- .env.example | 6 ++++++ .gitignore | 1 + app.js | 8 +++++--- 3 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..1f5bd41 --- /dev/null +++ b/.env.example @@ -0,0 +1,6 @@ +APP_ENV=local +APP_TOKEN=TEST + +SERVER_PORT=25053 +SERVER_IP=127.0.0.1 +DEFAULT_PONG_INTERVAL=3000 diff --git a/.gitignore b/.gitignore index 07e6e47..dc150eb 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /node_modules +.env diff --git a/app.js b/app.js index ca635a2..d939615 100644 --- a/app.js +++ b/app.js @@ -1,7 +1,9 @@ -const net = require("net"); +require('dotenv').config(); + +const net = require('net'); const client = new net.Socket(); -client.connect(25053, "127.0.0.1", () => { +client.connect(process.env.SERVER_PORT, process.env.SERVER_IP, () => { console.log("Connected"); client.write("First Ping ... \n"); }); @@ -13,7 +15,7 @@ client.on("data", (data) => { let sent = "Pong ... \n"; client.write(sent); console.log("Send: " + sent); - }, 3000); + }, process.env.DEFAULT_PONG_INTERVAL); }); client.on("close", () => { From 15266dc394494978729b6dc98761d6c8fc1a923c Mon Sep 17 00:00:00 2001 From: Ian Torres Date: Sun, 4 Apr 2021 18:47:31 -0400 Subject: [PATCH 2/3] Update .env.example --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 1f5bd41..f52b751 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,5 @@ APP_ENV=local -APP_TOKEN=TEST +APP_TOKEN=$2y$10$9z/ch9hTc5rNQF9ks7cQoui5ISEeTCa73Ixm3c2UiJawY33WrnuuG SERVER_PORT=25053 SERVER_IP=127.0.0.1 From 2bd512e560659e6cb762044fc34b465f1c907c67 Mon Sep 17 00:00:00 2001 From: Ian Torres Date: Sun, 4 Apr 2021 18:47:57 -0400 Subject: [PATCH 3/3] Update app.js --- app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.js b/app.js index 99997b0..c2b4951 100644 --- a/app.js +++ b/app.js @@ -3,7 +3,7 @@ require('dotenv').config(); const net = require('net'); const client = new net.Socket(); -const token = '$2y$10$9z/ch9hTc5rNQF9ks7cQoui5ISEeTCa73Ixm3c2UiJawY33WrnuuG'; +const token = process.env.APP_TOKEN; client.connect(process.env.SERVER_PORT, process.env.SERVER_IP, () => { console.log("Connected");