Skip to content

Commit 0cb2ae3

Browse files
committed
Dotenv and env example implemented (Closes #6).
1 parent 532ebe5 commit 0cb2ae3

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

.env.example

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
APP_ENV=local
2+
APP_TOKEN=TEST
3+
4+
SERVER_PORT=25053
5+
SERVER_IP=127.0.0.1
6+
DEFAULT_PONG_INTERVAL=3000

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/node_modules
2+
.env

app.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
const net = require("net");
1+
require('dotenv').config();
2+
3+
const net = require('net');
24
const client = new net.Socket();
35

4-
client.connect(25053, "127.0.0.1", () => {
6+
client.connect(process.env.SERVER_PORT, process.env.SERVER_IP, () => {
57
console.log("Connected");
68
client.write("First Ping ... \n");
79
});
@@ -13,7 +15,7 @@ client.on("data", (data) => {
1315
let sent = "Pong ... \n";
1416
client.write(sent);
1517
console.log("Send: " + sent);
16-
}, 3000);
18+
}, process.env.DEFAULT_PONG_INTERVAL);
1719
});
1820

1921
client.on("close", () => {

0 commit comments

Comments
 (0)