forked from linuxfoundation/crowd.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnoteCreate.ts
More file actions
29 lines (25 loc) · 958 Bytes
/
Copy pathnoteCreate.ts
File metadata and controls
29 lines (25 loc) · 958 Bytes
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
import Permissions from '../../security/permissions'
import NoteService from '../../services/noteService'
import PermissionChecker from '../../services/user/permissionChecker'
import track from '../../segment/track'
/**
* POST /tenant/{tenantId}/note
* @summary Create a note
* @tag Notes
* @security Bearer
* @description Create a note
* @pathParam {string} tenantId - Your workspace/tenant ID
* @bodyContent {NoteNoId} application/json
* @response 200 - Ok
* @responseContent {Note} 200.application/json
* @responseExample {Note} 200.application/json.Note
* @response 401 - Unauthorized
* @response 404 - Not found
* @response 429 - Too many requests
*/
export default async (req, res) => {
new PermissionChecker(req).validateHas(Permissions.values.noteCreate)
const payload = await new NoteService(req).create(req.body)
track('Note Created', { id: payload.id }, { ...req })
await req.responseHandler.success(req, res, payload)
}