MCPcopy
hub / github.com/chavyleung/scripts / apiSurge

Function apiSurge

chavy.box.js:927–951  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

925}
926
927async function apiSurge() {
928 const opts = $.toObj($request.body)
929 const httpapi = $.getdata('@chavy_boxjs_userCfgs.httpapi')
930 const ishttpapi = /.*?@.*?:[0-9]+/.test(httpapi)
931 if (
932 $.isSurge() &&
933 !$.isLoon() &&
934 !$.isShadowrocket() &&
935 !$.isStash() &&
936 ishttpapi
937 ) {
938 const [key, prefix] = httpapi.split('@')
939 opts.url = `http://${prefix}/${opts.url}`
940 opts.headers = {
941 'X-Key': key,
942 'Accept': 'application/json, text/plain, */*'
943 }
944 await new Promise((resolve) => {
945 $[opts.method.toLowerCase()](opts, (_, __, resp) => {
946 $.json = JSON.parse(resp)
947 resolve($.json)
948 })
949 })
950 }
951}
952
953async function apiSaveData() {
954 const { key: dataKey, val: dataVal } = $.toObj($request.body)

Callers

nothing calls this directly

Calls 6

toObjMethod · 0.45
getdataMethod · 0.45
isSurgeMethod · 0.45
isLoonMethod · 0.45
isShadowrocketMethod · 0.45
isStashMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…