MCPcopy Index your code
hub / github.com/chavyleung/scripts / handleApi

Function handleApi

chavy.box.js:277–302  ·  view source on GitHub ↗

* 处理 API 请求

()

Source from the content-addressed store, hash-verified

275 * 处理 API 请求
276 */
277async function handleApi() {
278 const [, api] = $.path.split('/api')
279
280 const apiHandlers = {
281 '/save': apiSave,
282 '/addAppSub': apiAddAppSub,
283 '/deleteAppSub': apiDeleteAppSub,
284 '/reloadAppSub': apiReloadAppSub,
285 '/delGlobalBak': apiDelGlobalBak,
286 '/updateGlobalBak': apiUpdateGlobalBak,
287 '/saveGlobalBak': apiSaveGlobalBak,
288 '/impGlobalBak': apiImpGlobalBak,
289 '/revertGlobalBak': apiRevertGlobalBak,
290 '/runScript': apiRunScript,
291 '/saveData': apiSaveData,
292 '/surge': apiSurge,
293 '/update': apiUpdate
294 }
295
296 for (const [key, handler] of Object.entries(apiHandlers)) {
297 if (api === key || api.startsWith(`${key}?`)) {
298 await handler()
299 break
300 }
301 }
302}
303
304async function handleOptions() {}
305

Callers 1

chavy.box.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…