Skip to content

Commit 0790b16

Browse files
committed
add dotenv support for environment variables and update MikroTik connection configuration
1 parent 40a114e commit 0790b16

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

.gitignore

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

index.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,18 @@ const RouterOSAPI = require("node-routeros").RouterOSAPI;
33
const WebSocket = require("ws");
44
const cors = require("cors");
55

6+
require("dotenv").config();
7+
68
const app = express();
79
const port = 3030;
810

911
app.use(cors());
1012

1113
// MikroTik connection configuration
1214
const connection = new RouterOSAPI({
13-
host: "192.168.1.6",
14-
user: "user-api",
15-
password: "123123",
15+
host: process.env.ROUTER_HOST,
16+
user: process.env.ROUTER_USER,
17+
password: process.env.ROUTER_PASSWORD,
1618
});
1719

1820
// WebSocket server setup

package-lock.json

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
"version": "1.0.0",
44
"main": "index.js",
55
"scripts": {
6-
"test": "echo \"Error: no test specified\" && exit 1"
6+
"test": "echo \"Error: no test specified\" && exit 1",
7+
"dev": "nodemon index.js"
78
},
89
"author": "Ismail",
910
"license": "ISC",
1011
"description": "",
1112
"dependencies": {
1213
"cors": "^2.8.5",
14+
"dotenv": "^16.4.7",
1315
"express": "^4.21.2",
1416
"node-routeros": "^1.6.8",
1517
"nodemon": "^3.1.9",

0 commit comments

Comments
 (0)