|
|
|
@ -60,11 +60,9 @@ export async function releaseVersion(_req: Request, res: Response) {
|
|
|
|
|
res.json(result); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function _axiosRequestMake(req: Request, res: Response, type: string) { |
|
|
|
|
async function _axiosRequestMake(req: Request, res: Response) { |
|
|
|
|
const { apiMeta } = req.body; |
|
|
|
|
if (type === 'csvUrl' || type === 'excelUrl') { |
|
|
|
|
apiMeta.responseType = 'arraybuffer'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (apiMeta?.body) { |
|
|
|
|
try { |
|
|
|
|
apiMeta.body = JSON.parse(apiMeta.body); |
|
|
|
@ -111,12 +109,21 @@ async function _axiosRequestMake(req: Request, res: Response, type: string) {
|
|
|
|
|
|
|
|
|
|
export async function axiosRequestMake(req: Request, res: Response) { |
|
|
|
|
const { |
|
|
|
|
apiMeta: { type } |
|
|
|
|
apiMeta: { url } |
|
|
|
|
} = req.body; |
|
|
|
|
if (type === 'csvUrl' || type === 'excelUrl') { |
|
|
|
|
return await _axiosRequestMake(req, res, type); |
|
|
|
|
const isExcelImport = /.*\.(xls|xlsx|xlsm|ods|ots)/; |
|
|
|
|
const isCSVImport = /.*\.(csv)/; |
|
|
|
|
const ipBlockList = /(10)(\.([2]([0-5][0-5]|[01234][6-9])|[1][0-9][0-9]|[1-9][0-9]|[0-9])){3}|(172)\.(1[6-9]|2[0-9]|3[0-1])(\.(2[0-4][0-9]|25[0-5]|[1][0-9][0-9]|[1-9][0-9]|[0-9])){2}|(192)\.(168)(\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])){2}|(0.0.0.0)|localhost?/g; |
|
|
|
|
if ( |
|
|
|
|
ipBlockList.test(url) || |
|
|
|
|
(!isCSVImport.test(url) && !isExcelImport.test(url)) |
|
|
|
|
) { |
|
|
|
|
return res.json({}); |
|
|
|
|
} |
|
|
|
|
if (isCSVImport || isExcelImport) { |
|
|
|
|
req.body.apiMeta.responseType = 'arraybuffer'; |
|
|
|
|
} |
|
|
|
|
return res.json({}); |
|
|
|
|
return await _axiosRequestMake(req, res); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export default router => { |
|
|
|
|