This commit is contained in:
2025-11-24 13:49:36 +08:00
parent 21b56d0948
commit 8b9fdb706f
43 changed files with 8123 additions and 622 deletions

View File

@@ -12,7 +12,7 @@ app.route({
}).define(async (ctx) => {
const query = ctx.query;
const page = query.page ?? 1;
const pageSize = query.pageSize ?? 10;
const pageSize = query.pageSize ?? 99999;
const db = getDb();
try {
const offset = (page - 1) * pageSize;
@@ -153,31 +153,3 @@ app.route({
ctx.throw(500, '获取数据详情失败');
}
}).addTo(app);
// 获取今日问题
app.route({
description: '获取今日问题',
path: 'daily',
key: 'today'
}).define(async (ctx) => {
const db = getDb();
try {
const allResults = await db.select().from(dailyQuestions);
// Sort by createdAt in descending order (newest first)
const sortedResults = allResults.sort((a, b) =>
new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
);
const result = sortedResults.slice(0, 1);
if (result.length === 0) {
ctx.throw(404, '暂无今日问题');
}
ctx.body = result[0];
} catch (error) {
console.error('获取今日问题失败:', error);
ctx.throw(500, '获取今日问题失败');
}
}).addTo(app);