forked from linuxfoundation/crowd.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtaskCreate.ts
More file actions
33 lines (29 loc) · 1 KB
/
Copy pathtaskCreate.ts
File metadata and controls
33 lines (29 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import Permissions from '../../security/permissions'
import TaskService from '../../services/taskService'
import PermissionChecker from '../../services/user/permissionChecker'
import track from '../../segment/track'
/**
* POST /tenant/{tenantId}/task
* @summary Create a task
* @tag Tasks
* @security Bearer
* @description Create a task
* @pathParam {string} tenantId - Your workspace/tenant ID
* @bodyContent {TaskInput} application/json
* @response 200 - Ok
* @responseContent {Task} 200.application/json
* @responseExample {Task} 200.application/json.Task
* @response 401 - Unauthorized
* @response 404 - Not found
* @response 429 - Too many requests
*/
export default async (req, res) => {
new PermissionChecker(req).validateHas(Permissions.values.taskCreate)
const payload = await new TaskService(req).create(req.body)
track(
'Task Created',
{ id: payload.id, dueDate: payload.dueDate, members: payload.members },
{ ...req },
)
await req.responseHandler.success(req, res, payload)
}