24 lines
613 B
TypeScript
24 lines
613 B
TypeScript
import { jsonError } from '@/lib/server/http';
|
|
import { requireAuthenticatedSession } from '@/lib/server/auth-session';
|
|
import { getTaskById } from '@/lib/server/tasks';
|
|
|
|
type Context = {
|
|
params: Promise<{ taskId: string }>;
|
|
};
|
|
|
|
export async function GET(_request: Request, context: Context) {
|
|
const { session, response } = await requireAuthenticatedSession();
|
|
if (response) {
|
|
return response;
|
|
}
|
|
|
|
const { taskId } = await context.params;
|
|
const task = await getTaskById(taskId, session.user.id);
|
|
|
|
if (!task) {
|
|
return jsonError('Task not found', 404);
|
|
}
|
|
|
|
return Response.json({ task });
|
|
}
|