integration of authentication

This commit is contained in:
2024-08-06 17:44:28 +02:00
parent 0c7fc6fdf7
commit ee932a2339
13 changed files with 153 additions and 84 deletions
+24 -9
View File
@@ -4,20 +4,39 @@ const lotDb = new LotDb();
const { SaleDb } = require("./saleDb");
const saleDb = new SaleDb();
const moment = require('moment-timezone');
const { config } = require("../config.js");
const Agent = class
{
constructor()
{
this.ApiAgentURL = "http://host.docker.internal:3020/api";
this.ApiAgentURL = config.agent.ApiAgentURL;
this.token = config.agent.token;
}
async request(url, method){
return new Promise((resolve, reject) => {
fetch(url,{
method: method,
headers: {
'authorization': this.token
}
})
.then(response => response.json())
.then(data => {
resolve(data);
})
.catch(error => {
reject(error);
});
});
}
async getSaleInfos(url)
{
return new Promise((resolve, reject) => {
url = encodeURIComponent(url);
fetch(this.ApiAgentURL+'/sale/getSaleInfos/'+url)
.then(response => response.json())
this.request(this.ApiAgentURL+'/sale/getSaleInfos/'+url, 'GET')
.then(data => {
resolve(data);
})
@@ -40,9 +59,7 @@ const Agent = class
let url = Sale.url
url = encodeURIComponent(url);
fetch(this.ApiAgentURL+'/sale/getLotList/'+url)
.then(response => response.json())
this.request(this.ApiAgentURL+'/sale/getLotList/'+url, 'GET')
.then( async data => {
for (let lot of data) {
@@ -68,9 +85,7 @@ const Agent = class
let url = Sale.url
url = encodeURIComponent(url);
fetch(this.ApiAgentURL+'/sale/followSale/'+url)
.then(response => response.json())
this.request(this.ApiAgentURL+'/sale/followSale/'+url, 'GET')
.then(async data => {
// set the Sale status to following
+1 -1
View File
@@ -1,5 +1,5 @@
const MongoClient = require("mongodb").MongoClient;
const config = require("../config.js");
const {config} = require("../config.js");
const connectionString = config.db.connectionString;
const client = new MongoClient(connectionString);