forked from linuxfoundation/crowd.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustomViewQuery.ts
More file actions
32 lines (28 loc) · 1.21 KB
/
Copy pathcustomViewQuery.ts
File metadata and controls
32 lines (28 loc) · 1.21 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
import Permissions from '../../security/permissions'
import CustomViewService from '../../services/customViewService'
import PermissionChecker from '../../services/user/permissionChecker'
import track from '../../segment/track'
/**
* GET /tenant/{tenantId}/customview/query
* @summary Query custom views
* @tag CustomViews
* @security Bearer
* @description Query custom views. It accepts filters and sorting options.
* @pathParam {string} tenantId - Your workspace/tenant ID
* @queryParam {string[]} placement - The placements to filter by
* @queryParam {string} visibility - The visibility to filter by
* @response 200 - Ok
* @responseContent {CustomViewList} 200.application/json
* @responseExample {CustomViewList} 200.application/json.CustomView
* @response 401 - Unauthorized
* @response 404 - Not found
* @response 429 - Too many requests
*/
export default async (req, res) => {
new PermissionChecker(req).validateHas(Permissions.values.activityRead)
const payload = await new CustomViewService(req).findAll(req.query)
if (req.query.filter && Object.keys(req.query.filter).length > 0) {
track('Custom views Filter', { ...payload }, { ...req })
}
await req.responseHandler.success(req, res, payload)
}