forked from linuxfoundation/crowd.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnoteQuery.ts
More file actions
31 lines (27 loc) · 1.07 KB
/
Copy pathnoteQuery.ts
File metadata and controls
31 lines (27 loc) · 1.07 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
import Permissions from '../../security/permissions'
import track from '../../segment/track'
import NoteService from '../../services/noteService'
import PermissionChecker from '../../services/user/permissionChecker'
/**
* POST /tenant/{tenantId}/note/query
* @summary Query notes
* @tag Notes
* @security Bearer
* @description Query notes. It accepts filters, sorting options and pagination.
* @pathParam {string} tenantId - Your workspace/tenant ID
* @bodyContent {NoteQuery} application/json
* @response 200 - Ok
* @responseContent {NoteList} 200.application/json
* @responseExample {NoteList} 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.noteRead)
const payload = await new NoteService(req).query(req.body)
if (req.query.filter && Object.keys(req.query.filter).length > 0) {
track('Notes Advanced Filter', { ...payload }, { ...req })
}
await req.responseHandler.success(req, res, payload)
}