biz-a-cli 2.2.0 → 2.3.1

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.
Files changed (3) hide show
  1. package/bin/hub.js +4 -18
  2. package/bin/index.js +11 -3
  3. package/package.json +1 -1
package/bin/hub.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  const yargs = require('yargs');
4
4
  const IDLE_SOCKET_TIMEOUT_MILLISECONDS = 1000 * 30;
@@ -59,16 +59,10 @@ return new Promise((resolve, reject) => {
59
59
 
60
60
  // clean and concat requested url
61
61
  let url;
62
- let subdomain = argv['subdomain'].toString();
62
+ // let subdomain = argv['subdomain'].toString();
63
63
  let server = argv['server'].toString();
64
64
 
65
- if (server.includes('https://')) {
66
- url = `https://${subdomain}.${server.slice(8)}`;
67
- } else if (server.includes('http://')) {
68
- url = `http://${subdomain}.${server.slice(7)}`;
69
- } else {
70
- url = `https://${subdomain}.${server}`;
71
- }
65
+ url = server;
72
66
 
73
67
  // resolve promise with requested URL
74
68
  resolve(url);
@@ -76,26 +70,18 @@ return new Promise((resolve, reject) => {
76
70
  });
77
71
  });
78
72
  socket.on('incomingClient', (clientId) => {
79
- // console.log(clientId, 'incoming clientId')
80
- // console.log(`connecting to ${argv['hostname']}:${argv['port']}`)
73
+ console.log(clientId, 'incoming clientId')
81
74
  let client = net.connect(argv['port'], argv['hostname']);
82
- // let client = net.createConnection(argv['port'], argv['hostname']);
83
75
 
84
76
  client.on('connect', () => {
85
77
  console.log(`client connected to ${argv['hostname']}:${argv['port']}`)
86
- // console.log('client:', client)
87
78
  let s = ss.createStream();
88
79
  s.pipe(client).pipe(s);
89
80
 
90
81
  s.on('end', () => {
91
82
  client.destroy();
92
83
  });
93
- // console.log(client, '<===client')
94
84
  ss(socket).emit(clientId, s);
95
-
96
- // s.on('data', (chunk)=>{
97
- // console.log(chunk.toString(), 'chunk')
98
- // })
99
85
  })
100
86
 
101
87
  client.setTimeout(IDLE_SOCKET_TIMEOUT_MILLISECONDS);
package/bin/index.js CHANGED
@@ -10,14 +10,22 @@ const { option, number } = require("yargs");
10
10
  const options = yargs
11
11
  .option("s", {alias:"server", describe:"Server URL", type:"string", demandOption:true})
12
12
  .option("i", {alias:"dbindex", describe:"database index", type:number, demandOption:true})
13
- .option("d", {alias:"dir", describe:"Directory", type:"string", demandOption:false})
13
+ // .option("d", {alias:"dir", describe:"Directory", type:"string", demandOption:false})
14
+ .option("sub", {alias:"subdomain", describe:"Subdomain", type:"string", demandOption:false})
14
15
  .argv;
15
16
 
16
17
  const sendFile = async (filename, data)=>{
17
- const url = `http://${options.server}:212/fina/rest/TOrmMethod/%22setTemplate%22`
18
+ const baseUrl = 'fina/rest/TOrmMethod/%22setTemplate%22'
19
+ const url = options.sub ?
20
+ `${options.server}/hub/${baseUrl}?subdomain=${options.sub}` :
21
+ `http://${options.server}:212/${baseUrl}`
22
+ // console.log('url', url)
18
23
 
24
+ const headers={
25
+ 'Content-Type':'text/plain'
26
+ }
19
27
  const param = {_parameters: [options.dbindex, filename, data]};
20
- return await axios.post(url, param);
28
+ return await axios.post(url, param, {headers:headers});
21
29
  }
22
30
 
23
31
  function getParam(funcName){
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "biz-a-cli",
3
- "version": "2.2.0",
3
+ "version": "2.3.1",
4
4
  "description": "",
5
5
  "main": "bin/index.js",
6
6
  "scripts": {