This commit is contained in:
2025-12-04 14:22:04 +08:00
parent 2a55f2d3ef
commit 9e458f4a77
17 changed files with 449 additions and 143 deletions

33
src/test/common.ts Normal file
View File

@@ -0,0 +1,33 @@
import { app } from '@/app.ts';
import '@/route.ts';
import { useConfig, useContextKey } from '@kevisual/context';
import { Query } from '@kevisual/query';
import util from 'node:util';
export {
app,
useContextKey
}
export const config = useConfig();
export const token = config.TOKEN || '';
export const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
export const showRes = (res, ...args) => {
if (res.code === 200) {
if (args.length === 0) {
console.log(res.code, util.inspect(res.body, { depth: 6, colors: true }));
return;
}
console.log(res.code, ...args);
} else {
console.error(res.code, res.message, ...args);
}
}
export const exit = (code = 0) => {
process.exit(code);
}
export const query = new Query({
url: 'https://kevisual.cn/api/router'
})

45
src/test/secret-key.ts Normal file
View File

@@ -0,0 +1,45 @@
import { app, token, showRes, sleep, useContextKey, exit, query } from './common.ts'
// await sleep(4000)
// const token2 = 'sk_6m3gjpkpny2ma9r96ei3bzck3kpg7b7g4oajghw7gmqoqk0vlh3swgxy85e0wnpt'
// await useContextKey('models-synced');
// const res = await app.call({
// path: 'secret',
// key: 'list',
// payload: {
// token,
// showToken: true
// }
// })
// showRes(res)
// const userRes = await app.call({
// path: 'user',
// key: 'me',
// payload: {
// token: token2,
// }
// })
// showRes(userRes)
// const openid = 'omcvy7AHC6bAA0QM4x9_bE0fGD1g'
// const res = await app.call({
// path: 'secret',
// key: 'wxnotify',
// payload: {
// openid
// }
// });
// showRes(res)
const res = await query.post({
path: 'secret',
key: 'wxnotify',
payload: {
openid: 'omcvy7M5CBAIB8TWDw6gNDHeHGeE'
}
})
showRes(res)
exit(0);