Browse Source

feat - getclientsummary api added

pull/1/head
khanshanawaz10 1 year ago
parent
commit
daf4e05339
7 changed files with 2068 additions and 5 deletions
  1. +2
    -0
      app.js
  2. +32
    -0
      controller/getHashvalue.js
  3. +67
    -0
      controller/getInvestmentSumarry.js
  4. +16
    -0
      controller/helper.js
  5. +1936
    -4
      package-lock.json
  6. +7
    -1
      package.json
  7. +8
    -0
      routes/script.js

+ 2
- 0
app.js View File

@ -12,6 +12,8 @@ const rfs = require('rotating-file-stream');
const logDirectory = path.join(__dirname, 'log')
const port = process.env.PORT || 5000;
// view engine setup
app.engine('pug', require('pug').__express)
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');


+ 32
- 0
controller/getHashvalue.js View File

@ -0,0 +1,32 @@
const crypto = require('crypto');
function generateHMACSHA256(input, key) {
const hmac = crypto.createHmac('sha256', key);
hmac.update(input, 'utf8'); // Ensure input encoding matches C# (UTF-8)
return hmac.digest('hex');
}
function getHashCode(type) {
const inputString = "||2023-11-22 14:57:38";
const inputString_GetInvestorDashboard = "368907||2023-11-22 14:57:38";
const inputString_GetTransactionById = "5151974||368907||2023-11-22 14:57:38";
const key = "27E6A91CEE689";
const hash = generateHMACSHA256(inputString, key);
const hash_GetInvestorDashboard = generateHMACSHA256(inputString_GetInvestorDashboard, key);
const hash_GetTransactionById = generateHMACSHA256(inputString_GetTransactionById, key);
if (type === 1) {
return hash
}
if (type === 2) {
return hash_GetInvestorDashboard
}
if (type === 3) {
return hash_GetTransactionById
}
}
module.exports = {
getHashCode
}

+ 67
- 0
controller/getInvestmentSumarry.js View File

@ -0,0 +1,67 @@
'use strict'
const request = require("request");
const constants = require('../utils/consts');
const db = require('../utils/db_config');
const crypto = require('crypto');
const { getCurrentDateTime } = require("./helper");
function generateHMACSHA256(input, key) {
const hmac = crypto.createHmac('sha256', key);
hmac.update(input, 'utf8'); // Ensure input encoding matches C# (UTF-8)
return hmac.digest('hex');
}
let arrayGetList = ["2509295", "2509", "2820644", "437290"]
function getHashCode(req) {
// console.log(`368907||${getCurrentDateTime()}`, "DKDDODKOODDOK");
const inputString_GetInvestorDashboard = `${req}||${getCurrentDateTime()}`;
const key = "27E6A91CEE689";
const hash_GetInvestorDashboard = generateHMACSHA256(inputString_GetInvestorDashboard, key);
return hash_GetInvestorDashboard
}
const createLiquiloanInvestor = async (req, res) => {
var promiseArray = [];
for (let i = 0; i < arrayGetList.length; i++) {
promiseArray.push(new Promise((resolve, reject) => {
var options = {
method: 'POST',
url: 'https://supply-integration.liquiloans.com/api/v2/GetInvestmentSummary',
headers: {
'Content-Type': 'application/json',
'Cookie': 'AWSALB=9yK+sr19KPz9dgL+OcWl2hZ9MOhLlvF9PtNolmRnkviHh01CvjlIWH44NtfjIziyJFwnhrn3+JNhztFLJis+Ijq971nXr5QQVJBxId1uvjZyqKSl/6oFuidGkloW; AWSALBCORS=9yK+sr19KPz9dgL+OcWl2hZ9MOhLlvF9PtNolmRnkviHh01CvjlIWH44NtfjIziyJFwnhrn3+JNhztFLJis+Ijq971nXr5QQVJBxId1uvjZyqKSl/6oFuidGkloW'
},
body: JSON.stringify({
"investor_id": arrayGetList[i],
"timestamp": getCurrentDateTime(),
"checksum": getHashCode(arrayGetList[i]),
"mid": "M00201"
})
};
request(options, function (error, response, body) {
if (error) reject(error);
else resolve(body)
})
}))
}
console.log(await Promise.all(promiseArray));
}
// const createLiquiloanInvestor = (req, res) => {
// for (let i = 0; i < arrayGetList.length; i++) {
// const element = arrayGetList[i];
// main(element, element.length)
// }
// res.se
// }
module.exports = {
createLiquiloanInvestor
}

+ 16
- 0
controller/helper.js View File

@ -0,0 +1,16 @@
function getCurrentDateTime() {
var date = new Date();
var dateStr =
date.getFullYear() + "-" +
("00" + (date.getMonth() + 1)).slice(-2) + "-" +
date.getDate() + " " +
("00" + date.getHours()).slice(-2) + ":" +
("00" + date.getMinutes()).slice(-2) + ":" +
("00" + date.getSeconds()).slice(-2);
return dateStr
}
module.exports = {
getCurrentDateTime
}

+ 1936
- 4
package-lock.json
File diff suppressed because it is too large
View File


+ 7
- 1
package.json View File

@ -4,7 +4,8 @@
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon app.js"
},
"repository": {
"type": "git",
@ -13,11 +14,16 @@
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^1.6.2",
"cookie-parser": "^1.4.6",
"crypto": "^1.0.1",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"morgan": "^1.10.0",
"node-cron": "^3.0.3",
"nodemon": "^3.0.2",
"pug": "^3.0.2",
"request": "^2.88.2",
"rotating-file-stream": "^3.1.1",
"sequelize": "^6.35.1",
"tedious": "^16.6.1"


+ 8
- 0
routes/script.js View File

@ -1,6 +1,14 @@
const express = require('express');
const { route } = require("express/lib/application");
const { createLiquiloanInvestor } = require('../controller/getInvestmentSumarry');
const router = express.Router();
router.get("/api/v1", (req, res) => {
// res.send("HELLO I M A NEW COURSE NODE.JS")
createLiquiloanInvestor()
})
/* GET users listing. */


Loading…
Cancel
Save

Powered by TurnKey Linux.