Task: Updated sdk client and updated the missing types for http tunnel client

This commit is contained in:
Sambo Chea 2022-07-09 21:17:08 +07:00
parent 23c7bda220
commit 1af63d5955
Signed by: sombochea
GPG Key ID: 3C7CF22A05D95490
3 changed files with 11 additions and 12 deletions

3
.gitignore vendored
View File

@ -1,2 +1,3 @@
node_modules/
npm-debug.log
npm-debug.log
dist/

View File

@ -9,7 +9,7 @@ import { TunnelRequest, TunnelResponse } from "./lib";
import { generateUUID, addPrefixOnHttpSchema } from "./util";
import { Socket } from 'socket.io-client';
const sdk = require("../sdk");
import { getTokenFree } from './sdk'
const packageInfo = require("../package.json");
@ -276,9 +276,8 @@ program
if (!config.token) {
console.log("Generating token...");
await sdk
.getTokenFree(config.server)
.then((resp) => {
await getTokenFree(config.server)
.then((resp: any) => {
if (resp.data?.token) {
config.token = resp.data?.token;
} else {
@ -286,7 +285,7 @@ program
return;
}
})
.catch((err) => {
.catch((err: any) => {
console.error("cannot get free token from server", err);
return;
});
@ -430,9 +429,8 @@ program
// FREE
if (config.access === TOKEN_FREE) {
await sdk
.getTokenFree(config.server)
.then((resp) => {
await getTokenFree(config.server)
.then((resp: any) => {
if (resp.data?.token) {
config.token = resp.data?.token;
} else {
@ -440,7 +438,7 @@ program
return;
}
})
.catch((err) => {
.catch((err: any) => {
console.error("cannot get free token from server", err);
return;
});

View File

@ -1,6 +1,6 @@
const axios = require("axios").default;
const getTokenFree = async (baseUrl, data = {}) => {
const getTokenFree = async (baseUrl: string, data: any = {}) => {
const url = `${baseUrl}/__free__/api/get_token`;
return axios({
method: "POST",
@ -14,6 +14,6 @@ const getTokenFree = async (baseUrl, data = {}) => {
});
};
module.exports = {
export {
getTokenFree,
};