Config via env

This commit is contained in:
Nicolai Ort 2023-04-25 19:32:50 +02:00
parent c70ca41fd7
commit 0c83d84276
Signed by: niggl
GPG Key ID: 13AFA55AF62F269F
2 changed files with 15 additions and 8 deletions

View File

@ -1,6 +1,7 @@
{ {
"dependencies": { "dependencies": {
"@odit/lfk-client-node": "^1.1.1" "@odit/lfk-client-node": "^1.1.1",
"dotenv": "^16.0.3"
}, },
"type": "module" "type": "module"
} }

View File

@ -1,11 +1,17 @@
import { AuthService, OpenAPI, RunnerService, RunnerTeamService, ScanService } from "@odit/lfk-client-node"; import { AuthService, OpenAPI, RunnerService, RunnerTeamService, ScanService } from "@odit/lfk-client-node";
import * as dotenv from 'dotenv';
dotenv.config()
const groupID = 3; const groupID = 3;
const distanceMeter = 69; const distanceMeter = 69;
OpenAPI.BASE = process.env.BASE_URL || "http://localhost:4010"; OpenAPI.BASE = process.env.BASE_URL;
const user = process.env.USER || "demo"; const user = process.env.USER;
const password = process.env.PASSWORD || "demo"; const password = process.env.PASSWORD;
if(!user || !password || !OpenAPI.BASE){
process.exit(1)
}
const auth = await AuthService.authControllerLogin({ username: user, password }); const auth = await AuthService.authControllerLogin({ username: user, password });
OpenAPI.TOKEN = auth.access_token; OpenAPI.TOKEN = auth.access_token;