added file upload handler to tasks
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user