biz-a-cli 2.3.35 → 2.3.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,39 +20,8 @@ export function getInputScript(req) {
20
20
  }
21
21
  }
22
22
 
23
- function rawHeadersToHeaders(rawHeaders) {
24
- const headers = {};
25
-
26
- for (let headerIdx = 0; headerIdx < rawHeaders.length; headerIdx += 2) {
27
- const key = rawHeaders[headerIdx].toLowerCase();
28
- const value = rawHeaders[headerIdx + 1];
29
-
30
- if (headers[key]) {
31
- headers[key] += `, ${value}`;
32
- } else {
33
- headers[key] = value;
34
- }
35
- }
36
-
37
- return headers;
38
- }
39
-
40
- export function setDirectHubData(req) {
41
- return {
42
- body: {
43
- query: req.query,
44
- body: req.body,
45
- headers: rawHeadersToHeaders(req.rawHeaders)
46
- }
47
- }
48
- }
49
-
50
23
  export async function runCliScript(req, res) {
51
24
  try {
52
- if (!req.body.query) {
53
- Object.assign(req, setDirectHubData(req))
54
- };
55
-
56
25
  const { data, selectedConfig } = getInputScript(req);
57
26
  let script = await loadCliScript(selectedConfig, 'ID', req.body.query.scriptid);
58
27
  let functions = await extractFunctionScript(selectedConfig, script);
package/envs/env.dev.js CHANGED
@@ -7,11 +7,4 @@ export const envDev = {
7
7
  COMPANY_REGISTER: 'companyregister-dev',
8
8
  BIZA_SERVER_LINK: 'https://biz-a-dev-41e7c93a25e5.herokuapp.com',
9
9
  // BIZA_SERVER_LINK: 'http://localhost:3000',
10
- ESPAY_INQUIRY_LINK: 'http://localhost:3002/cb?subdomain=anejandev&companyid=anejandev&scriptid=5',
11
- ESPAY_PAYMENT_LINK: 'http://localhost:3002/cb?subdomain=SACHLI&companyid=immdev&scriptid=6',
12
- // ESPAY_INQUIRY_LINK: 'https://biz-a.herokuapp.com/cb?subdomain=anejandev&companyid=anejandev&scriptid=5',
13
- // ESPAY_PAYMENT_LINK: 'https://biz-a.herokuapp.com/cb?subdomain=SACHLI&companyid=immdev&scriptid=6',
14
-
15
-
16
-
17
10
  };
package/envs/env.js CHANGED
@@ -6,9 +6,4 @@ export const env = {
6
6
  encodeURIComponent('imm@2019') + '@imm-cdm.ohcqt.mongodb.net/?retryWrites=true&w=majority',
7
7
  COMPANY_REGISTER: 'companyregister',
8
8
  BIZA_SERVER_LINK: 'https://biz-a.herokuapp.com',
9
- // ESPAY_INQUIRY_LINK: 'http://localhost:3002/cb?subdomain=scya&companyid=scy&scriptid=5',
10
- ESPAY_INQUIRY_LINK: 'http://localhost:3002/cb?subdomain=anejan&companyid=anejan&scriptid=4',
11
- ESPAY_PAYMENT_LINK: 'http://localhost:3002/cb?subdomain=imm&companyid=imamatek&scriptid=7',
12
- // ESPAY_INQUIRY_LINK: 'https://biz-a.herokuapp.com/cb?subdomain=anejandev&companyid=anejandev&scriptid=5',
13
- // ESPAY_PAYMENT_LINK: 'https://biz-a.herokuapp.com/cb?subdomain=SACHLI&companyid=immdev&scriptid=6',
14
9
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "biz-a-cli",
3
3
  "nameDev": "biz-a-cli-dev",
4
- "version": "2.3.35",
4
+ "version": "2.3.37",
5
5
  "versionDev": "0.0.30",
6
6
  "description": "",
7
7
  "main": "bin/index.js",
@@ -26,8 +26,7 @@
26
26
  "watcher": "bin/watcher.js",
27
27
  "uploadapp": "bin/uploadApp.js",
28
28
  "deleteapp": "bin/deleteApp.js",
29
- "biza": "bin/app.js",
30
- "pmtGateway": "bin/pmtGateway.js"
29
+ "biza": "bin/app.js"
31
30
  },
32
31
  "dependencies": {
33
32
  "axios": "^1.6.8",
@@ -1,6 +1,5 @@
1
1
  const {
2
- getInputScript,
3
- setDirectHubData
2
+ getInputScript
4
3
  } = await import('../callbackController.js');
5
4
 
6
5
  describe('callback test', () => {
@@ -40,20 +39,4 @@ describe('callback test', () => {
40
39
  }
41
40
  });
42
41
  });
43
-
44
- test('get input script', () => {
45
- const req = {
46
- query: { 'a': 1 },
47
- body: { 'b': 2 },
48
- rawHeaders: ['Abc-Xyz', 'def']
49
- }
50
-
51
- expect(setDirectHubData(req)).toStrictEqual({
52
- body: {
53
- query: { 'a': 1 },
54
- body: { 'b': 2 },
55
- headers: { 'abc-xyz': 'def' }
56
- }
57
- })
58
- });
59
42
  })
package/bin/pmtGateway.js DELETED
@@ -1,68 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import yargs from 'yargs';
4
- import { createLogger, transports, format } from "winston";
5
- import {
6
- sendInquiry,
7
- sendPaymentNotif,
8
- } from "../pmtGatewayController.js";
9
-
10
-
11
- const logger = createLogger({
12
- level: 'info',
13
- transports: [
14
- new transports.File({ filename: 'log/error.log', level: 'error' }),
15
- new transports.File({ filename: 'log/debug.log', level: 'debug' }),
16
- new transports.File({ filename: 'log/info.log', level: 'info' }),
17
- ],
18
- })
19
- if (process.env.NODE_ENV !== 'production') {
20
- logger.add(new transports.Console({ format: format.simple(), level: 'info' }))
21
- }
22
-
23
- process.on('uncaughtException', (err) => { //debug
24
- console.log('Unhandled Exception:', err);
25
- logger.error('Unhandled Exception:', err)
26
- });
27
-
28
- process.on('unhandledRejection', (err) => { //debug
29
- console.log('Unhandled Rejection:', err);
30
- logger.error('Unhandled Rejection:', err)
31
- });
32
-
33
- const port = 3003;
34
- const argv = yargs(process.argv.slice(2))
35
- .usage('Usage: $0 [options]')
36
- .options('sp', {
37
- alias: 'serverport',
38
- default: port,
39
- describe: 'Express Port (Callback Feature)',
40
- type: 'number',
41
- demandOption: false
42
- })
43
- .argv;
44
-
45
- if (argv.help) {
46
- yargs().showHelp();
47
- process.exit();
48
- }
49
-
50
- //
51
- import express from 'express';
52
- import cors from 'cors';
53
- const app = express();
54
-
55
- app.use(cors());
56
- app.use(express.json());
57
-
58
- app.set('args', argv);
59
-
60
- app.use('/v1.0/transfer-va/inquiry', sendInquiry);
61
- app.use('/v1.0/transfer-va/payment', sendPaymentNotif);
62
-
63
- app.listen((argv.serverport || port), () => {
64
- console.log(`Biz-A is listening at ${process.env.HOST || 'http://localhost'}:${argv.serverport || port} `);
65
- });
66
- //
67
-
68
- export { app }
@@ -1,55 +0,0 @@
1
- import { default as axios } from 'axios';
2
- import { envDev } from './envs/env.dev.js';
3
- import { env } from './envs/env.js';
4
-
5
- import dayjs from "dayjs";
6
- import utc from "dayjs/plugin/utc.js";
7
- import timezone from "dayjs/plugin/timezone.js"
8
-
9
- dayjs.extend(timezone)
10
- dayjs.extend(utc)
11
-
12
- const TIME_FORMAT = 'YYYY-MM-DDTHH:mm:ssZ'
13
- let ESPAY_INQUIRY_LINK;
14
- let ESPAY_PAYMENT_LINK;
15
-
16
- if ((process.env.NODE_ENV == undefined) || (process.env.NODE_ENV == 'development')) {
17
- ESPAY_INQUIRY_LINK = envDev.ESPAY_INQUIRY_LINK;
18
- ESPAY_PAYMENT_LINK = envDev.ESPAY_PAYMENT_LINK;
19
-
20
- console.log('ESPAY_INQUIRY_LINK =>', ESPAY_INQUIRY_LINK);
21
- console.log('ESPAY_PAYMENT_LINK =>', ESPAY_PAYMENT_LINK);
22
- } else {
23
- ESPAY_INQUIRY_LINK = env.ESPAY_INQUIRY_LINK;
24
- ESPAY_PAYMENT_LINK = env.ESPAY_PAYMENT_LINK;
25
- }
26
-
27
- async function sendData(req, res, url) {
28
- const headers = {
29
- 'content-type': req.headers['content-type'],
30
- 'x-timestamp': req.headers['x-timestamp'],
31
- 'x-signature': req.headers['x-signature'],
32
- 'channel-id': req.headers['channel-id'],
33
- 'x-external-id': req.headers['x-external-id'],
34
- 'x-partner-id': req.headers['x-partner-id'],
35
- 'imm-original-url': req.originalUrl
36
- }
37
-
38
- res.setHeader('x-timestamp', dayjs().tz('Asia/jakarta').format(TIME_FORMAT));
39
-
40
- const result = await axios.post(url, req.body, { headers });
41
- res.send(result.data);
42
- }
43
-
44
- async function sendInquiry(req, res) {
45
- await sendData(req, res, ESPAY_INQUIRY_LINK);
46
- }
47
-
48
- async function sendPaymentNotif(req, res) {
49
- await sendData(req, res, ESPAY_PAYMENT_LINK);
50
- }
51
-
52
- export {
53
- sendInquiry,
54
- sendPaymentNotif
55
- };