mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-06 20:26:28 +00:00
Compare commits
96 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c8f01db5e9 | |||
| 1be5cc8d0c | |||
| 352ec2822f | |||
| 9910d4d834 | |||
| a2eb984658 | |||
| eac57a3821 | |||
| f4451aaea2 | |||
| 837d1c5d77 | |||
| 74825d277b | |||
| 8c231e9901 | |||
| 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 { param, body, validationResult } = require('express-validator');
|
||||||
const winston = require("../../helpers/winston.logger");
|
const winston = require('../../helpers/winston.logger');
|
||||||
const generate = require("./utils/utils");
|
const generate = require('./utils/utils');
|
||||||
const loadBalance = require("../loadbalance/loadbalance.controller");
|
const loadBalance = require('../loadbalance/loadbalance.controller');
|
||||||
const _sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
const _sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
require("dotenv").config();
|
require('dotenv').config();
|
||||||
|
|
||||||
let useClient;
|
let useClient;
|
||||||
|
|
||||||
// set connection HSM server
|
// set connection HSM server
|
||||||
if (process.env.NUMBER_SERVER_ACTIVE == "1") {
|
if (process.env.NUMBER_SERVER_ACTIVE == '1') {
|
||||||
var { client } = require("./services/webSocket");
|
var { client } = require('./services/webSocket');
|
||||||
|
|
||||||
useClient = client;
|
useClient = client;
|
||||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "2") {
|
} else if (process.env.NUMBER_SERVER_ACTIVE == '2') {
|
||||||
var { client2 } = require("./services/webSocket2");
|
var { client2 } = require('./services/webSocket2');
|
||||||
|
|
||||||
useClient = client2;
|
useClient = client2;
|
||||||
} else if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
} else if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||||
var { client } = require("./services/webSocket");
|
var { client } = require('./services/webSocket');
|
||||||
var { client2 } = require("./services/webSocket2");
|
var { client2 } = require('./services/webSocket2');
|
||||||
}
|
}
|
||||||
|
|
||||||
// VALIDATION
|
// VALIDATION
|
||||||
const validate = (method) => {
|
const validate = (method) => {
|
||||||
switch (method) {
|
switch (method) {
|
||||||
case "topup":
|
case 'topup':
|
||||||
return [
|
return [
|
||||||
body("mid").not().isEmpty().withMessage("MID is required"),
|
body('mid').not().isEmpty().withMessage('MID is required'),
|
||||||
body("tid").not().isEmpty().withMessage("TID is required"),
|
body('tid').not().isEmpty().withMessage('TID is required'),
|
||||||
body("uid").not().isEmpty().withMessage("UID is required"),
|
body('uid').not().isEmpty().withMessage('UID is required'),
|
||||||
body("flag").not().isEmpty().withMessage("Flag is required"),
|
body('flag').not().isEmpty().withMessage('Flag is required'),
|
||||||
body("card_number")
|
body('card_number')
|
||||||
.not()
|
.not()
|
||||||
.isEmpty()
|
.isEmpty()
|
||||||
.withMessage("Card Number is required"),
|
.withMessage('Card Number is required'),
|
||||||
body("amount")
|
body('amount')
|
||||||
.not()
|
.not()
|
||||||
.isEmpty()
|
.isEmpty()
|
||||||
.withMessage("Amount is required")
|
.withMessage('Amount is required')
|
||||||
.isNumeric()
|
.isNumeric()
|
||||||
.withMessage("Amount is invalid format"),
|
.withMessage('Amount is invalid format'),
|
||||||
body("reservation_number")
|
body('reservation_number')
|
||||||
.not()
|
.not()
|
||||||
.isEmpty()
|
.isEmpty()
|
||||||
.withMessage("Reservation Number is required")
|
.withMessage('Reservation Number is required')
|
||||||
.isArray()
|
.isArray()
|
||||||
.withMessage("Reservation Number is invalid request format"),
|
.withMessage('Reservation Number is invalid request format'),
|
||||||
];
|
];
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -66,6 +66,7 @@ const controller = async (req, res) => {
|
|||||||
uid,
|
uid,
|
||||||
balance,
|
balance,
|
||||||
flag,
|
flag,
|
||||||
|
execution_id,
|
||||||
unique_code,
|
unique_code,
|
||||||
trxID,
|
trxID,
|
||||||
requestData,
|
requestData,
|
||||||
@@ -75,7 +76,7 @@ const controller = async (req, res) => {
|
|||||||
let result = {};
|
let result = {};
|
||||||
|
|
||||||
// set connection HSM server
|
// set connection HSM server
|
||||||
if (process.env.NUMBER_SERVER_ACTIVE == "12") {
|
if (process.env.NUMBER_SERVER_ACTIVE == '12') {
|
||||||
// set request to HSM server 2
|
// set request to HSM server 2
|
||||||
if (uniqueCode) {
|
if (uniqueCode) {
|
||||||
if (parseInt(uniqueCode) % 2 == 0) {
|
if (parseInt(uniqueCode) % 2 == 0) {
|
||||||
@@ -101,7 +102,7 @@ const controller = async (req, res) => {
|
|||||||
const err = validationResult(req, res);
|
const err = validationResult(req, res);
|
||||||
if (!err.isEmpty()) {
|
if (!err.isEmpty()) {
|
||||||
result = {
|
result = {
|
||||||
code: "400",
|
code: '400',
|
||||||
message: err.errors[0].msg,
|
message: err.errors[0].msg,
|
||||||
data: {},
|
data: {},
|
||||||
};
|
};
|
||||||
@@ -122,6 +123,14 @@ const controller = async (req, res) => {
|
|||||||
let transactionId = Buffer.from(generate.hexToBytes(trxID));
|
let transactionId = Buffer.from(generate.hexToBytes(trxID));
|
||||||
let trxrequestData = Buffer.from(generate.hexToBytes(requestData));
|
let trxrequestData = Buffer.from(generate.hexToBytes(requestData));
|
||||||
let _stopMessage = 1;
|
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 apiId = Buffer.from([0x04]);
|
||||||
let reqData = generate.makeRequestData(
|
let reqData = generate.makeRequestData(
|
||||||
@@ -136,7 +145,7 @@ const controller = async (req, res) => {
|
|||||||
let respData = null;
|
let respData = null;
|
||||||
let respData1 = null;
|
let respData1 = null;
|
||||||
|
|
||||||
useClient.ws.on("message", (message) => {
|
useClient.ws.on('message', (message) => {
|
||||||
while (
|
while (
|
||||||
message[2] == 4 &&
|
message[2] == 4 &&
|
||||||
message[0] == transactionId[0] &&
|
message[0] == transactionId[0] &&
|
||||||
@@ -188,15 +197,16 @@ const controller = async (req, res) => {
|
|||||||
balance: balance,
|
balance: balance,
|
||||||
flag: flag,
|
flag: flag,
|
||||||
unique_code: unique_code,
|
unique_code: unique_code,
|
||||||
|
execution_id: execID,
|
||||||
};
|
};
|
||||||
|
|
||||||
// insert data load balance
|
// insert data load balance
|
||||||
let insert = await loadBalance.loadingBalanceInsert(data);
|
let insert = await loadBalance.loadingBalanceInsert(data);
|
||||||
if (insert) {
|
if (insert) {
|
||||||
if (insert.code == "00") {
|
if (insert.code == '00') {
|
||||||
result = {
|
result = {
|
||||||
code: "00",
|
code: '00',
|
||||||
message: "Generate Write Succeess",
|
message: 'Generate Write Succeess',
|
||||||
data: {
|
data: {
|
||||||
trxID: generate.buf2hex(transactionId),
|
trxID: generate.buf2hex(transactionId),
|
||||||
responseCode: respCode,
|
responseCode: respCode,
|
||||||
@@ -214,8 +224,8 @@ const controller = async (req, res) => {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result = {
|
result = {
|
||||||
code: "423",
|
code: '423',
|
||||||
message: "update/insert failed",
|
message: 'update/insert failed',
|
||||||
data: {},
|
data: {},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -233,11 +243,11 @@ const controller = async (req, res) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return res.status(200).send({
|
return res.status(200).send({
|
||||||
code: "5001",
|
code: '5001',
|
||||||
message:
|
message:
|
||||||
process.env.NODE_ENV != "production"
|
process.env.NODE_ENV != 'production'
|
||||||
? error.message
|
? error.message
|
||||||
: "500 internal server error - backend server.",
|
: '500 internal server error - backend server.',
|
||||||
data: {},
|
data: {},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
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 host;
|
||||||
let database;
|
let database;
|
||||||
@@ -6,77 +6,77 @@ let port;
|
|||||||
let user;
|
let user;
|
||||||
let password;
|
let password;
|
||||||
|
|
||||||
if (process.env.SERVER_FOR == "local") {
|
if (process.env.SERVER_FOR == 'local') {
|
||||||
host = "localhost";
|
host = 'localhost';
|
||||||
database = "postgres";
|
database = 'postgres';
|
||||||
port = 5432;
|
port = 5432;
|
||||||
user = "postgres";
|
user = 'postgres';
|
||||||
password = "postgres";
|
password = 'postgres';
|
||||||
} else if (process.env.SERVER_FOR == "development") {
|
} else if (process.env.SERVER_FOR == 'development') {
|
||||||
host = "10.20.14.14";
|
host = '10.20.14.14';
|
||||||
database = "postgres";
|
database = 'postgres';
|
||||||
port = 5432;
|
port = 5432;
|
||||||
user = "cms";
|
user = 'postgres';
|
||||||
password = "Cm5kc1#2021";
|
password = 'inhc0mmute_cms';
|
||||||
} else if (process.env.SERVER_FOR == "production") {
|
} else if (process.env.SERVER_FOR == 'production') {
|
||||||
host = "10.1.201.75";
|
host = '10.1.201.75';
|
||||||
database = "postgres";
|
database = 'postgres';
|
||||||
port = 5432;
|
port = 5432;
|
||||||
user = "postgres";
|
user = 'postgres';
|
||||||
password = "inhc0mmute_cms";
|
password = 'inhc0mmute_cms';
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
// development: {
|
// development: {
|
||||||
// client: "pg",
|
// client: "pg",
|
||||||
// connection: process.env.DB_URL,
|
// connection: process.env.DB_URL,
|
||||||
// migrations: {
|
// migrations: {
|
||||||
// directory: "./infrastructure/database/migrations",
|
// directory: "./infrastructure/database/migrations",
|
||||||
// },
|
// },
|
||||||
// seeds: { directory: "./infrastructure/database/seeds" },
|
// seeds: { directory: "./infrastructure/database/seeds" },
|
||||||
// },
|
// },
|
||||||
development: {
|
development: {
|
||||||
client: "pg",
|
client: 'pg',
|
||||||
connection: {
|
connection: {
|
||||||
host: host,
|
host: host,
|
||||||
database: database,
|
database: database,
|
||||||
user: user,
|
user: user,
|
||||||
password: password,
|
password: password,
|
||||||
},
|
|
||||||
// connection: process.env.DB_URL,
|
|
||||||
pool: {
|
|
||||||
min: 2,
|
|
||||||
max: 10,
|
|
||||||
},
|
|
||||||
migrations: {
|
|
||||||
directory: "./infrastructure/database/migrations",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
// connection: process.env.DB_URL,
|
||||||
|
pool: {
|
||||||
|
min: 2,
|
||||||
|
max: 10,
|
||||||
|
},
|
||||||
|
migrations: {
|
||||||
|
directory: './infrastructure/database/migrations',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
testing: {
|
testing: {
|
||||||
client: "pg",
|
client: 'pg',
|
||||||
connection: process.env.DB_URL,
|
connection: process.env.DB_URL,
|
||||||
migrations: {
|
migrations: {
|
||||||
directory: "./infrastructure/database/migrations",
|
directory: './infrastructure/database/migrations',
|
||||||
},
|
|
||||||
seeds: { directory: "./infrastructure/database/seeds" },
|
|
||||||
},
|
},
|
||||||
|
seeds: { directory: './infrastructure/database/seeds' },
|
||||||
|
},
|
||||||
|
|
||||||
production: {
|
production: {
|
||||||
client: "pg",
|
client: 'pg',
|
||||||
connection: {
|
connection: {
|
||||||
host: host,
|
host: host,
|
||||||
database: database,
|
database: database,
|
||||||
user: user,
|
user: user,
|
||||||
password: password,
|
password: password,
|
||||||
},
|
|
||||||
// connection: process.env.DB_URL,
|
|
||||||
pool: {
|
|
||||||
min: 2,
|
|
||||||
max: 10,
|
|
||||||
},
|
|
||||||
migrations: {
|
|
||||||
directory: "./infrastructure/database/migrations",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
// connection: process.env.DB_URL,
|
||||||
|
pool: {
|
||||||
|
min: 2,
|
||||||
|
max: 10,
|
||||||
|
},
|
||||||
|
migrations: {
|
||||||
|
directory: './infrastructure/database/migrations',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user