MCPcopy Create free account
hub / github.com/RealDevSquad/website-backend / createProgress

Function createProgress

controllers/progresses.js:48–78  ·  view source on GitHub ↗
(req, res)

Source from the content-addressed store, hash-verified

46 */
47
48const createProgress = async (req, res) => {
49 if (req.userData.roles?.archived || req.userData.roles?.in_discord !== true) {
50 return res.boom.forbidden(UNAUTHORIZED_WRITE);
51 }
52
53 const {
54 body: { type, completed, planned, blockers, taskId },
55 } = req;
56 try {
57 const { data, taskTitle } = await progressesModel.createProgressDocument({ ...req.body, userId: req.userData.id });
58 await sendTaskUpdate(completed, blockers, planned, req.userData.username, taskId, taskTitle);
59 return res.status(201).json({
60 data,
61 message: `${type.charAt(0).toUpperCase() + type.slice(1)} ${PROGRESS_DOCUMENT_CREATED_SUCCEEDED}`,
62 });
63 } catch (error) {
64 if (error instanceof Conflict) {
65 return res.status(409).json({
66 message: error.message,
67 });
68 } else if (error instanceof NotFound) {
69 return res.status(404).json({
70 message: error.message,
71 });
72 }
73 logger.error(error.message);
74 return res.status(500).json({
75 message: INTERNAL_SERVER_ERROR_MESSAGE,
76 });
77 }
78};
79
80/**
81 * @typedef {Object} ProgressQueryParams

Callers

nothing calls this directly

Calls 1

sendTaskUpdateFunction · 0.85

Tested by

no test coverage detected