UNPKG

trm-core

Version:

TRM (Transport Request Manager) Core

34 lines (33 loc) 846 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const axios_1 = __importDefault(require("axios")); const url_1 = __importDefault(require("url")); const args = process.argv; var endpoint; var protocolUrl; try { endpoint = args[2]; protocolUrl = args[3]; } catch (e) { } if (!endpoint || !protocolUrl) { throw new Error("Missing arguments."); } var urlParse; try { urlParse = url_1.default.parse(protocolUrl, true); } catch (e) { throw new Error("Couldn't parse URL."); } axios_1.default.post(endpoint, { path: urlParse.href, parameters: urlParse.query }).then(() => { console.log("Callback called."); }).catch(err => { console.error(err); });