revisi lib

This commit is contained in:
Sas Andy
2024-09-27 10:22:27 +07:00
parent 2d83b3dc0d
commit 62ef52eda5
7 changed files with 247 additions and 70 deletions

View File

@@ -3,9 +3,52 @@ import config from "./config/config";
import logging from "./config/logging";
import { NAME_SPACE } from "./server";
export const getMember = async () => {
const url = config.base_url + "tools/member/Membergateway/getmemberv2";
logging.info(NAME_SPACE, "\t INFO : " + url);
try {
const resp = await axios.get(url, {
responseType: "arraybuffer",
});
const jresp = JSON.parse(resp.data.toString());
return jresp;
} catch (e) {
if (axios.isAxiosError(e)) {
logging.error(NAME_SPACE, e.response?.data.toString());
} else if (e instanceof Error) {
logging.error(NAME_SPACE, e.message);
}
}
};
export const uploadV2 = async (prm: any) => {
const url = config.base_url + "tools/member/Membergateway/uploadV2";
logging.info(NAME_SPACE, "\t INFO : " + url);
// logging.info(NAME_SPACE, "PRM : ", prm);
try {
const resp = await axios.post(
url,
{
debug: "N",
data: prm,
},
{
headers: { "Content-Type": "application/json; charset=UTF-8" },
responseType: "arraybuffer",
}
);
const jresp = JSON.parse(resp.data.toString());
return jresp;
} catch (e) {
if (axios.isAxiosError(e)) {
logging.error(NAME_SPACE, e.response?.data.toString());
} else if (e instanceof Error) {
logging.error(NAME_SPACE, e.message);
}
}
};
export const upload = async () => {
const url = config.base_url + "tools/member/Membergateway/upload";
logging.info(NAME_SPACE, "INFO : " + url);
logging.info(NAME_SPACE, "\t INFO : " + url);
try {
const resp = await axios.get(url, {
responseType: "arraybuffer",
@@ -22,7 +65,7 @@ export const upload = async () => {
};
export const download = async () => {
const url = config.base_url + "tools/member/Membergateway/download";
logging.info(NAME_SPACE, "INFO : " + url);
logging.info(NAME_SPACE, "\t INFO : " + url);
try {
const resp = await axios.get(url, {
responseType: "arraybuffer",
@@ -37,9 +80,50 @@ export const download = async () => {
}
}
};
export const downloadV2 = async () => {
const url = config.base_url + "tools/member/Membergateway/downloadV2";
logging.info(NAME_SPACE, "\t INFO : " + url);
try {
const resp = await axios.get(url, {
responseType: "arraybuffer",
});
const jresp = JSON.parse(resp.data.toString());
return jresp;
} catch (e) {
if (axios.isAxiosError(e)) {
logging.error(NAME_SPACE, e.response?.data.toString());
} else if (e instanceof Error) {
logging.error(NAME_SPACE, e.message);
}
}
};
export const generate = async (prm: any) => {
const url = config.base_url + "tools/member/Membergateway/generateV2";
logging.info(NAME_SPACE, "\t INFO : " + url);
try {
const resp = await axios.post(
url,
{
data: prm,
},
{
headers: { "Content-Type": "application/json; charset=UTF-8" },
responseType: "arraybuffer",
}
);
const jresp = JSON.parse(resp.data.toString());
return jresp;
} catch (e) {
if (axios.isAxiosError(e)) {
logging.error(NAME_SPACE, e.response?.data.toString());
} else if (e instanceof Error) {
logging.error(NAME_SPACE, e.message);
}
}
};
export const getDataNatInfo = async () => {
const url = config.base_url + "tools/member/downloadinfo/downloadInfo";
logging.info(NAME_SPACE, "INFO : " + url);
logging.info(NAME_SPACE, "\t INFO : " + url);
try {
const resp = await axios.get(url, {
responseType: "arraybuffer",
@@ -67,7 +151,7 @@ export const insertNatInfo = async (
visit +
"/" +
point;
logging.info(NAME_SPACE, "INFO : " + url);
logging.info(NAME_SPACE, "\t INFO : " + url);
try {
const resp = await axios.get(url, {
responseType: "arraybuffer",