added file upload handler to tasks

This commit is contained in:
2025-02-14 12:48:24 +05:30
parent a933c25f34
commit 5276f2a6cb
5 changed files with 56 additions and 2 deletions

View File

@@ -1,10 +1,11 @@
import { FastifyReply, FastifyRequest } from "fastify";
import { CreateTaskInput, UpdateTaskInput } from "./task.schema";
import { CreateTaskInput, UpdateTaskInput, UploadTaskInput } from "./task.schema";
import {
createTask,
deleteTask,
getTask,
listTasks,
newUpload,
searchTasks,
updateTask,
} from "./task.service";
@@ -97,3 +98,17 @@ export async function searchTaskHandler(
return err;
}
}
export async function newFilesHandler(req: FastifyRequest, res: FastifyReply) {
const input = req.body as UploadTaskInput;
const { taskId } = req.params as { taskId: string };
try {
const updatedTask = await newUpload(taskId, input, req.user);
if (!updateTask) return res.code(404).send({ error: "resource not found" });
return res.code(200).send(updateTask);
} catch (err) {
return err;
}
}