mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-06 10:56:27 +00:00
Compare commits
87 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4495f910b0 | |||
| f7c5cf33f6 | |||
| 870d8aea46 | |||
| b46d3a5b25 | |||
| 5408639d80 | |||
| 9b2ab48e99 | |||
| a35492c124 | |||
| e1f0c60b37 | |||
| 16afd42876 | |||
| 3722be6eeb | |||
| 493f131779 | |||
| f10ff80284 | |||
| f30ee86552 | |||
| e8de33b663 | |||
| 68ebfb0ac2 | |||
| 96c46ad49c | |||
| 10e38babcd | |||
| 8bc68493cf | |||
| 2b1b14548a | |||
| 240bb5fa17 | |||
| 7676ec54ef | |||
| de0a8847b5 | |||
| 4df41a426c | |||
| 3401e425b4 | |||
| 0d29175942 | |||
| 4f03433bb2 | |||
| 1df5f97543 | |||
| a222714bcb | |||
| 2249bbbbaf | |||
| 16fbfdcae1 | |||
| 6b5f92e597 | |||
| baf99a975d | |||
| 70b9ef78cb | |||
| 4169b40e97 | |||
| 3566f63bea | |||
| 066fd49173 | |||
| 2c0ffbd9d6 | |||
| ee46232c7a | |||
| 15131cebb1 | |||
| 6ff785de5a | |||
| 8e997346d2 | |||
| 80dda817fb | |||
| 410ef5ac53 | |||
| d9d5be8921 | |||
| 574092e015 | |||
| 5ece7912f4 | |||
| 2540b1c6c0 | |||
| 4feb7a7724 | |||
| 4994278078 | |||
| c6488f7f69 | |||
| f0bbf54afc | |||
| 7c6ab450be | |||
| 1524d643c6 | |||
| 36b61697dd | |||
| 8366d9b38b | |||
| ed7e0ce127 | |||
| 8d1e2075c3 | |||
| 5df52be111 | |||
| 6e0627fb86 | |||
| 0235cdb7c0 | |||
| a64c38b928 | |||
| 99f004adf2 | |||
| 3e5d73dd56 | |||
| 4481079289 | |||
| 9bc1260bc0 | |||
| df8ad92eba | |||
| 3b8d9d20ff | |||
| 5197966807 | |||
| 966c7b1f60 | |||
| 002f1375e4 | |||
| ada8358c07 | |||
| b587640684 | |||
| 7d56ebbe77 | |||
| 015832c683 | |||
| 79a5c5951b | |||
| c54a030519 | |||
| 775b36cfd2 | |||
| b796bfdd5c | |||
| 25f66afa7b | |||
| 162c742e76 | |||
| e60e38d28b | |||
| 47072d156d | |||
| c60b00dbcf | |||
| 089fb2131a | |||
| 40a408ab9d | |||
| a89f84fc18 | |||
| 95ab81bcc6 |
@@ -1,51 +1,51 @@
|
||||
const { param, body, validationResult } = require("express-validator");
|
||||
const winston = require("../../helpers/winston.logger");
|
||||
const generate = require("./utils/utils");
|
||||
const loadBalance = require("../loadbalance/loadbalance.controller");
|
||||
const { param, body, validationResult } = require('express-validator');
|
||||
const winston = require('../../helpers/winston.logger');
|
||||
const generate = require('./utils/utils');
|
||||
const loadBalance = require('../loadbalance/loadbalance.controller');
|
||||
const _sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||
require("dotenv").config();
|
||||
require('dotenv').config();
|
||||
|
||||
let useClient;
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "1") {
|
||||
var { client } = require("./services/webSocket");
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
||||
var { client } = require('./services/webSocket');
|
||||
|
||||
useClient = client;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "2") {
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '2') {
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
|
||||
useClient = client2;
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
var { client } = require("./services/webSocket");
|
||||
var { client2 } = require("./services/webSocket2");
|
||||
} else if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
var { client } = require('./services/webSocket');
|
||||
var { client2 } = require('./services/webSocket2');
|
||||
}
|
||||
|
||||
// VALIDATION
|
||||
const validate = (method) => {
|
||||
switch (method) {
|
||||
case "topup":
|
||||
case 'topup':
|
||||
return [
|
||||
body("mid").not().isEmpty().withMessage("MID is required"),
|
||||
body("tid").not().isEmpty().withMessage("TID is required"),
|
||||
body("uid").not().isEmpty().withMessage("UID is required"),
|
||||
body("flag").not().isEmpty().withMessage("Flag is required"),
|
||||
body("card_number")
|
||||
body('mid').not().isEmpty().withMessage('MID is required'),
|
||||
body('tid').not().isEmpty().withMessage('TID is required'),
|
||||
body('uid').not().isEmpty().withMessage('UID is required'),
|
||||
body('flag').not().isEmpty().withMessage('Flag is required'),
|
||||
body('card_number')
|
||||
.not()
|
||||
.isEmpty()
|
||||
.withMessage("Card Number is required"),
|
||||
body("amount")
|
||||
.withMessage('Card Number is required'),
|
||||
body('amount')
|
||||
.not()
|
||||
.isEmpty()
|
||||
.withMessage("Amount is required")
|
||||
.withMessage('Amount is required')
|
||||
.isNumeric()
|
||||
.withMessage("Amount is invalid format"),
|
||||
body("reservation_number")
|
||||
.withMessage('Amount is invalid format'),
|
||||
body('reservation_number')
|
||||
.not()
|
||||
.isEmpty()
|
||||
.withMessage("Reservation Number is required")
|
||||
.withMessage('Reservation Number is required')
|
||||
.isArray()
|
||||
.withMessage("Reservation Number is invalid request format"),
|
||||
.withMessage('Reservation Number is invalid request format'),
|
||||
];
|
||||
default:
|
||||
break;
|
||||
@@ -66,6 +66,7 @@ const controller = async (req, res) => {
|
||||
uid,
|
||||
balance,
|
||||
flag,
|
||||
execution_id,
|
||||
unique_code,
|
||||
trxID,
|
||||
requestData,
|
||||
@@ -75,7 +76,7 @@ const controller = async (req, res) => {
|
||||
let result = {};
|
||||
|
||||
// set connection HSM server
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
||||
if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||
// set request to HSM server 2
|
||||
if (uniqueCode) {
|
||||
if (parseInt(uniqueCode) % 2 == 0) {
|
||||
@@ -101,7 +102,7 @@ const controller = async (req, res) => {
|
||||
const err = validationResult(req, res);
|
||||
if (!err.isEmpty()) {
|
||||
result = {
|
||||
code: "400",
|
||||
code: '400',
|
||||
message: err.errors[0].msg,
|
||||
data: {},
|
||||
};
|
||||
@@ -122,6 +123,14 @@ const controller = async (req, res) => {
|
||||
let transactionId = Buffer.from(generate.hexToBytes(trxID));
|
||||
let trxrequestData = Buffer.from(generate.hexToBytes(requestData));
|
||||
let _stopMessage = 1;
|
||||
let execID;
|
||||
if (execution_id) {
|
||||
execID = execution_id;
|
||||
} else {
|
||||
let execByte = Buffer.alloc(2);
|
||||
trxrequestData.copy(execByte, 0, 24, 26);
|
||||
execID = generate.buf2hex(execByte);
|
||||
}
|
||||
|
||||
let apiId = Buffer.from([0x04]);
|
||||
let reqData = generate.makeRequestData(
|
||||
@@ -136,7 +145,7 @@ const controller = async (req, res) => {
|
||||
let respData = null;
|
||||
let respData1 = null;
|
||||
|
||||
useClient.ws.on("message", (message) => {
|
||||
useClient.ws.on('message', (message) => {
|
||||
while (
|
||||
message[2] == 4 &&
|
||||
message[0] == transactionId[0] &&
|
||||
@@ -188,15 +197,16 @@ const controller = async (req, res) => {
|
||||
balance: balance,
|
||||
flag: flag,
|
||||
unique_code: unique_code,
|
||||
execution_id: execID,
|
||||
};
|
||||
|
||||
// insert data load balance
|
||||
let insert = await loadBalance.loadingBalanceInsert(data);
|
||||
if (insert) {
|
||||
if (insert.code == "00") {
|
||||
if (insert.code == '00') {
|
||||
result = {
|
||||
code: "00",
|
||||
message: "Generate Write Succeess",
|
||||
code: '00',
|
||||
message: 'Generate Write Succeess',
|
||||
data: {
|
||||
trxID: generate.buf2hex(transactionId),
|
||||
responseCode: respCode,
|
||||
@@ -214,8 +224,8 @@ const controller = async (req, res) => {
|
||||
}
|
||||
} else {
|
||||
result = {
|
||||
code: "423",
|
||||
message: "update/insert failed",
|
||||
code: '423',
|
||||
message: 'update/insert failed',
|
||||
data: {},
|
||||
};
|
||||
}
|
||||
@@ -233,11 +243,11 @@ const controller = async (req, res) => {
|
||||
);
|
||||
|
||||
return res.status(200).send({
|
||||
code: "5001",
|
||||
code: '5001',
|
||||
message:
|
||||
process.env.NODE_ENV != "production"
|
||||
process.env.NODE_ENV != 'production'
|
||||
? error.message
|
||||
: "500 internal server error - backend server.",
|
||||
: '500 internal server error - backend server.',
|
||||
data: {},
|
||||
});
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+65
-65
@@ -1,4 +1,4 @@
|
||||
require("dotenv").config();
|
||||
require('dotenv').config();
|
||||
|
||||
let host;
|
||||
let database;
|
||||
@@ -6,77 +6,77 @@ let port;
|
||||
let user;
|
||||
let password;
|
||||
|
||||
if (process.env.SERVER_FOR == "local") {
|
||||
host = "localhost";
|
||||
database = "postgres";
|
||||
if (process.env.SERVER_FOR == 'local') {
|
||||
host = 'localhost';
|
||||
database = 'postgres';
|
||||
port = 5432;
|
||||
user = "postgres";
|
||||
password = "postgres";
|
||||
} else if (process.env.SERVER_FOR == "development") {
|
||||
host = "10.20.14.14";
|
||||
database = "postgres";
|
||||
user = 'postgres';
|
||||
password = 'postgres';
|
||||
} else if (process.env.SERVER_FOR == 'development') {
|
||||
host = '10.20.14.14';
|
||||
database = 'postgres';
|
||||
port = 5432;
|
||||
user = "cms";
|
||||
password = "Cm5kc1#2021";
|
||||
} else if (process.env.SERVER_FOR == "production") {
|
||||
host = "10.1.201.75";
|
||||
database = "postgres";
|
||||
user = 'postgres';
|
||||
password = 'inhc0mmute_cms';
|
||||
} else if (process.env.SERVER_FOR == 'production') {
|
||||
host = '10.1.201.75';
|
||||
database = 'postgres';
|
||||
port = 5432;
|
||||
user = "postgres";
|
||||
password = "inhc0mmute_cms";
|
||||
user = 'postgres';
|
||||
password = 'inhc0mmute_cms';
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
// development: {
|
||||
// client: "pg",
|
||||
// connection: process.env.DB_URL,
|
||||
// migrations: {
|
||||
// directory: "./infrastructure/database/migrations",
|
||||
// },
|
||||
// seeds: { directory: "./infrastructure/database/seeds" },
|
||||
// },
|
||||
development: {
|
||||
client: "pg",
|
||||
connection: {
|
||||
host: host,
|
||||
database: database,
|
||||
user: user,
|
||||
password: password,
|
||||
},
|
||||
// connection: process.env.DB_URL,
|
||||
pool: {
|
||||
min: 2,
|
||||
max: 10,
|
||||
},
|
||||
migrations: {
|
||||
directory: "./infrastructure/database/migrations",
|
||||
},
|
||||
module.exports = {
|
||||
// development: {
|
||||
// client: "pg",
|
||||
// connection: process.env.DB_URL,
|
||||
// migrations: {
|
||||
// directory: "./infrastructure/database/migrations",
|
||||
// },
|
||||
// seeds: { directory: "./infrastructure/database/seeds" },
|
||||
// },
|
||||
development: {
|
||||
client: 'pg',
|
||||
connection: {
|
||||
host: host,
|
||||
database: database,
|
||||
user: user,
|
||||
password: password,
|
||||
},
|
||||
// connection: process.env.DB_URL,
|
||||
pool: {
|
||||
min: 2,
|
||||
max: 10,
|
||||
},
|
||||
migrations: {
|
||||
directory: './infrastructure/database/migrations',
|
||||
},
|
||||
},
|
||||
|
||||
testing: {
|
||||
client: "pg",
|
||||
connection: process.env.DB_URL,
|
||||
migrations: {
|
||||
directory: "./infrastructure/database/migrations",
|
||||
},
|
||||
seeds: { directory: "./infrastructure/database/seeds" },
|
||||
testing: {
|
||||
client: 'pg',
|
||||
connection: process.env.DB_URL,
|
||||
migrations: {
|
||||
directory: './infrastructure/database/migrations',
|
||||
},
|
||||
seeds: { directory: './infrastructure/database/seeds' },
|
||||
},
|
||||
|
||||
production: {
|
||||
client: "pg",
|
||||
connection: {
|
||||
host: host,
|
||||
database: database,
|
||||
user: user,
|
||||
password: password,
|
||||
},
|
||||
// connection: process.env.DB_URL,
|
||||
pool: {
|
||||
min: 2,
|
||||
max: 10,
|
||||
},
|
||||
migrations: {
|
||||
directory: "./infrastructure/database/migrations",
|
||||
},
|
||||
production: {
|
||||
client: 'pg',
|
||||
connection: {
|
||||
host: host,
|
||||
database: database,
|
||||
user: user,
|
||||
password: password,
|
||||
},
|
||||
};
|
||||
// connection: process.env.DB_URL,
|
||||
pool: {
|
||||
min: 2,
|
||||
max: 10,
|
||||
},
|
||||
migrations: {
|
||||
directory: './infrastructure/database/migrations',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user