2022-11-23 07:49:19 +13:00
|
|
|
import Router from "@koa/router"
|
2022-11-23 08:49:59 +13:00
|
|
|
import * as controller from "../controllers/user"
|
2022-11-23 07:49:19 +13:00
|
|
|
import authorized from "../../middleware/authorized"
|
|
|
|
import { permissions } from "@budibase/backend-core"
|
2023-11-21 09:52:29 +13:00
|
|
|
|
2022-11-23 07:49:19 +13:00
|
|
|
const { PermissionType, PermissionLevel } = permissions
|
2020-04-30 07:29:42 +12:00
|
|
|
|
2022-11-23 07:49:19 +13:00
|
|
|
const router: Router = new Router()
|
2020-04-30 07:29:42 +12:00
|
|
|
|
2020-05-05 04:13:57 +12:00
|
|
|
router
|
2020-11-12 06:34:15 +13:00
|
|
|
.get(
|
2021-04-09 03:58:33 +12:00
|
|
|
"/api/users/metadata",
|
2022-11-18 03:59:18 +13:00
|
|
|
authorized(PermissionType.USER, PermissionLevel.READ),
|
2021-04-09 03:58:33 +12:00
|
|
|
controller.fetchMetadata
|
2020-11-12 06:34:15 +13:00
|
|
|
)
|
|
|
|
.get(
|
2021-04-20 03:26:33 +12:00
|
|
|
"/api/users/metadata/:id",
|
2022-11-18 03:59:18 +13:00
|
|
|
authorized(PermissionType.USER, PermissionLevel.READ),
|
2021-04-09 03:58:33 +12:00
|
|
|
controller.findMetadata
|
2020-11-12 06:34:15 +13:00
|
|
|
)
|
|
|
|
.put(
|
2021-04-09 03:58:33 +12:00
|
|
|
"/api/users/metadata",
|
2022-11-18 03:59:18 +13:00
|
|
|
authorized(PermissionType.USER, PermissionLevel.WRITE),
|
2021-04-09 03:58:33 +12:00
|
|
|
controller.updateMetadata
|
2020-11-12 06:34:15 +13:00
|
|
|
)
|
2021-04-21 04:17:44 +12:00
|
|
|
.post(
|
|
|
|
"/api/users/metadata/self",
|
2022-11-18 03:59:18 +13:00
|
|
|
authorized(PermissionType.USER, PermissionLevel.WRITE),
|
2021-04-21 04:17:44 +12:00
|
|
|
controller.updateSelfMetadata
|
|
|
|
)
|
2020-05-22 01:31:23 +12:00
|
|
|
.delete(
|
2021-04-20 03:26:33 +12:00
|
|
|
"/api/users/metadata/:id",
|
2022-11-18 03:59:18 +13:00
|
|
|
authorized(PermissionType.USER, PermissionLevel.WRITE),
|
2021-04-09 03:58:33 +12:00
|
|
|
controller.destroyMetadata
|
2020-05-22 01:31:23 +12:00
|
|
|
)
|
2021-12-08 07:24:10 +13:00
|
|
|
.post(
|
|
|
|
"/api/users/flags",
|
2022-11-18 03:59:18 +13:00
|
|
|
authorized(PermissionType.USER, PermissionLevel.WRITE),
|
2021-12-08 07:24:10 +13:00
|
|
|
controller.setFlag
|
|
|
|
)
|
|
|
|
.get(
|
|
|
|
"/api/users/flags",
|
2022-11-18 03:59:18 +13:00
|
|
|
authorized(PermissionType.USER, PermissionLevel.READ),
|
2021-12-08 07:24:10 +13:00
|
|
|
controller.getFlags
|
|
|
|
)
|
2020-04-30 07:29:42 +12:00
|
|
|
|
2023-01-11 22:37:37 +13:00
|
|
|
export default router
|