easy-api.ts
Version:
A powerful library to create your own API with ease.
1 lines • 980 B
JavaScript
Object.defineProperty(exports,"__esModule",{value:!0});let tslib_1=require("tslib"),APIFunction_1=require("../../classes/structures/APIFunction"),Error_1=require("../../classes/structures/Error"),_=tslib_1.__importStar(require("lodash"));class HTTPResult extends APIFunction_1.APIFunction{name="$httpResult";description="Retrieves a property from the HTTP request response.";parameters=[{name:"Path",description:"Property key path to be retrieved.",type:APIFunction_1.ParamType.String,required:!0,rest:!1,defaultValue:null}];usage="$httpResult[path]";returns=APIFunction_1.ParamType.Unknown;compile=!0;aliases=[];async run(e,[t]){var r;if(e.internalVarExists("EATS_REQUEST"))return r=e.getInternalVar("EATS_REQUEST"),void 0===(r="%default%"===t.toLowerCase()?JSON.stringify(r.body):_.get(r.body,t))?"null":"object"==typeof r?JSON.stringify(r):"string"!=typeof r?r.toString():r;throw new Error_1.EATS_Error("Missing request data in: "+e.function?.name)}}exports.default=HTTPResult;