mirror of
https://github.com/whyour/qinglong.git
synced 2026-11-30 16:27:21 +08:00
Return committed trigger IDs and add CLI wait and trigger-specific logs while preserving API, CLI, transaction, deduplication and unknown-result semantics. Move scheduling, lifecycle, settlement, queries and legacy adapters into back/cron; remove obsolete internal import paths and circular dependencies. Apply project formatting across the repository, cover CJS/MJS in formatting hooks, add prettier:check and require formatting checks in AGENTS.md. Validation: backend build; 1398 backend/frontend tests passed (17 platform skips); 327 CLI tests passed (6 platform skips); 670 files pass format checks.
55 lines
1.9 KiB
JavaScript
55 lines
1.9 KiB
JavaScript
const { test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const ts = require('typescript');
|
|
const { openOperations } = require('../../dist/remote/api/openOperations');
|
|
|
|
test('body-consuming backend routes expose a CLI request body or upload', () => {
|
|
const root = path.resolve(__dirname, '../../../back/api');
|
|
let checked = 0;
|
|
for (const filename of fs
|
|
.readdirSync(root)
|
|
.filter((name) => name.endsWith('.ts'))) {
|
|
const text = fs.readFileSync(path.join(root, filename), 'utf8');
|
|
const mount = text.match(/app\.use\(['"]([^'"]+)/)?.[1];
|
|
if (!mount) continue;
|
|
const source = ts.createSourceFile(
|
|
filename,
|
|
text,
|
|
ts.ScriptTarget.Latest,
|
|
true,
|
|
);
|
|
const visit = (node) => {
|
|
if (
|
|
ts.isCallExpression(node) &&
|
|
ts.isPropertyAccessExpression(node.expression) &&
|
|
node.expression.expression.getText(source) === 'route' &&
|
|
['post', 'put', 'delete'].includes(node.expression.name.text) &&
|
|
node.arguments[0] &&
|
|
ts.isStringLiteral(node.arguments[0]) &&
|
|
/\breq\.body\b/.test(node.getText(source))
|
|
) {
|
|
const endpoint = [mount, node.arguments[0].text]
|
|
.join('/')
|
|
.split('/')
|
|
.filter(Boolean)
|
|
.join('/');
|
|
const method = node.expression.name.text.toUpperCase();
|
|
const operation = openOperations.find(
|
|
(item) => item.method === method && item.path === endpoint,
|
|
);
|
|
assert.ok(operation, `${method} ${endpoint} is missing`);
|
|
assert.ok(
|
|
operation.body || operation.upload,
|
|
`${operation.name} cannot provide req.body`,
|
|
);
|
|
checked++;
|
|
}
|
|
ts.forEachChild(node, visit);
|
|
};
|
|
visit(source);
|
|
}
|
|
assert.ok(checked > 0, 'No body-consuming routes were inspected');
|
|
});
|