| 12345678910111213141516171819202122232425262728293031323334 |
- // 测试 user-consumption 路由
- import { testClient } from 'hono/testing';
- import dataOverviewRoutes from './packages/data-overview-module-mt/src/routes/index.js';
- async function testRoute() {
- const client = testClient(dataOverviewRoutes);
- // 尝试调用 userConsumption 端点
- try {
- const response = await client.userConsumption.$get({
- query: {
- page: '1',
- limit: '10',
- timeRange: 'last30days'
- }
- }, {
- headers: {
- 'Authorization': 'Bearer test-token'
- }
- });
- console.log('Response status:', response.status);
- if (response.status === 401) {
- console.log('认证失败(预期中)');
- } else {
- const text = await response.text();
- console.log('Response body:', text.substring(0, 200));
- }
- } catch (error) {
- console.error('Error:', error);
- }
- }
- testRoute();
|