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

Function handleQuery

chavy.box.js:221–272  ·  view source on GitHub ↗

* 处理`查询`请求

()

Source from the content-addressed store, hash-verified

219 * 处理`查询`请求
220 */
221async function handleQuery() {
222 const referer = $request.headers.referer || $request.headers.Referer
223 if (!/^https?:\/\/(.+\.)?boxjs\.(com|net)\//.test(referer)) {
224 const isMuteQueryAlert = [true, 'true'].includes(
225 $.getdata('@chavy_boxjs_userCfgs.isMuteQueryAlert')
226 )
227
228 if (!isMuteQueryAlert) {
229 // 关闭静默状态
230 const _isMute = $.isMute
231 $.isMute = false
232
233 $.msg(
234 $.name,
235 '❗️发现有脚本或人正在读取你的数据',
236 [
237 '请注意数据安全, 你可以: ',
238 '1. 在 BoxJs 的脚本日志中查看详情',
239 '2. 在 BoxJs 的页面 (侧栏) 中 "不显示查询警告"'
240 ].join('\n')
241 )
242
243 // 还原静默状态
244 $.isMute = _isMute
245 }
246
247 $.log(
248 [
249 '',
250 '❗️❗️❗️ 发现有脚本或人正在读取你的数据 ❗️❗️❗️',
251 JSON.stringify($request),
252 ''
253 ].join('\n')
254 )
255 }
256
257 const [, query] = $.path.split('/query')
258 if (/^\/boxdata/.test(query)) {
259 $.json = getBoxData()
260 } else if (/^\/baks/.test(query)) {
261 const [, backupId] = query.split('/baks/')
262 $.json = $.getjson(backupId)
263 } else if (/^\/versions$/.test(query)) {
264 await getVersions(true)
265 } else if (/^\/data/.test(query)) {
266 const [, dataKey] = query.split('/data/')
267 $.json = {
268 key: dataKey,
269 val: $.getdata(dataKey)
270 }
271 }
272}
273
274/**
275 * 处理 API 请求

Callers 1

chavy.box.jsFile · 0.70

Calls 6

getBoxDataFunction · 0.70
getVersionsFunction · 0.70
getdataMethod · 0.45
msgMethod · 0.45
logMethod · 0.45
getjsonMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…