MCPcopy Create free account
hub / github.com/Semporia/Scripts / runScript

Method runScript

jd_try.js:621–643  ·  view source on GitHub ↗
(script, runOpts)

Source from the content-addressed store, hash-verified

619 }
620
621 runScript(script, runOpts) {
622 return new Promise((resolve) => {
623 let httpapi = this.getdata('@chavy_boxjs_userCfgs.httpapi')
624 httpapi = httpapi ? httpapi.replace(/\n/g, '').trim() : httpapi
625 let httpapi_timeout = this.getdata('@chavy_boxjs_userCfgs.httpapi_timeout')
626 httpapi_timeout = httpapi_timeout ? httpapi_timeout * 1 : 20
627 httpapi_timeout = runOpts && runOpts.timeout ? runOpts.timeout : httpapi_timeout
628 const [key, addr] = httpapi.split('@')
629 const opts = {
630 url: `http://${addr}/v1/scripting/evaluate`,
631 body: {
632 script_text: script,
633 mock_type: 'cron',
634 timeout: httpapi_timeout
635 },
636 headers: {
637 'X-Key': key,
638 'Accept': '*/*'
639 }
640 }
641 this.post(opts, (err, resp, body) => resolve(body))
642 }).catch((e) => this.logErr(e))
643 }
644
645 loaddata() {
646 if (this.isNode()) {

Callers

nothing calls this directly

Calls 3

getdataMethod · 0.45
postMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected