update: get auth token with every request

This commit is contained in:
mahyargdz
2024-12-09 13:15:54 +03:30
parent 4603468ef1
commit d6c7d9b82a
3 changed files with 22 additions and 12 deletions
+13 -5
View File
@@ -1,6 +1,6 @@
/* eslint-disable node/handle-callback-err */
const axios = require('axios')
const { verityAxiosConfig, panatechAxiosConfig } = require('../ArpaWebservice')
const { verityAxiosConfig, panatechAxiosConfig, getVerityToken, getPanatechToken } = require('../ArpaWebservice')
function axiosConfig(db) {
if (db === 'verity') return verityAxiosConfig()
else if (db === 'panatech') return panatechAxiosConfig()
@@ -9,7 +9,9 @@ function axiosConfig(db) {
/// //// cross server requests
module.exports.getRouteManager = [
(req, res) => {
async (req, res) => {
await getVerityToken()
await getPanatechToken()
const { url, db } = req.body
axios
.get(url, axiosConfig(db))
@@ -26,7 +28,9 @@ module.exports.getRouteManager = [
}
]
module.exports.postRouteManager = [
(req, res) => {
async (req, res) => {
await getVerityToken()
await getPanatechToken()
const { url, db, data } = req.body
axios
.post(url, data, axiosConfig(db))
@@ -41,7 +45,9 @@ module.exports.postRouteManager = [
}
]
module.exports.putRouteManager = [
(req, res) => {
async (req, res) => {
await getVerityToken()
await getPanatechToken()
const { url, db, data } = req.body
axios
.put(url, data, axiosConfig(db))
@@ -56,7 +62,9 @@ module.exports.putRouteManager = [
}
]
module.exports.deleteRouteManager = [
(req, res) => {
async (req, res) => {
await getVerityToken()
await getPanatechToken()
const { url, db, data } = req.body
axios
.delete(url, data, axiosConfig(db))