flatten app to repo root and update docker deployment for single-stack runtime
This commit is contained in:
17
app/api/tasks/[taskId]/route.ts
Normal file
17
app/api/tasks/[taskId]/route.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { jsonError } from '@/lib/server/http';
|
||||
import { getTaskById } from '@/lib/server/tasks';
|
||||
|
||||
type Context = {
|
||||
params: Promise<{ taskId: string }>;
|
||||
};
|
||||
|
||||
export async function GET(_request: Request, context: Context) {
|
||||
const { taskId } = await context.params;
|
||||
const task = await getTaskById(taskId);
|
||||
|
||||
if (!task) {
|
||||
return jsonError('Task not found', 404);
|
||||
}
|
||||
|
||||
return Response.json({ task });
|
||||
}
|
||||
20
app/api/tasks/route.ts
Normal file
20
app/api/tasks/route.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import type { TaskStatus } from '@/lib/types';
|
||||
import { listRecentTasks } from '@/lib/server/tasks';
|
||||
|
||||
const ALLOWED_STATUSES: TaskStatus[] = ['queued', 'running', 'completed', 'failed'];
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const url = new URL(request.url);
|
||||
const limitValue = Number(url.searchParams.get('limit') ?? 20);
|
||||
const limit = Number.isFinite(limitValue)
|
||||
? Math.min(Math.max(Math.trunc(limitValue), 1), 200)
|
||||
: 20;
|
||||
|
||||
const rawStatuses = url.searchParams.getAll('status');
|
||||
const statuses = rawStatuses.filter((status): status is TaskStatus => {
|
||||
return ALLOWED_STATUSES.includes(status as TaskStatus);
|
||||
});
|
||||
|
||||
const tasks = await listRecentTasks(limit, statuses.length > 0 ? statuses : undefined);
|
||||
return Response.json({ tasks });
|
||||
}
|
||||
Reference in New Issue
Block a user