2020-05-07 11:53:34 +02:00
|
|
|
const Router = require("@koa/router")
|
|
|
|
const controller = require("../controllers/user")
|
2020-05-21 15:31:23 +02:00
|
|
|
const authorized = require("../../middleware/authorized")
|
|
|
|
const { USER_MANAGEMENT, LIST_USERS } = require("../../utilities/accessLevels")
|
2020-10-07 18:56:47 +02:00
|
|
|
const usage = require("../../middleware/usageQuota")
|
2020-04-29 21:29:42 +02:00
|
|
|
|
2020-05-07 11:53:34 +02:00
|
|
|
const router = Router()
|
2020-04-29 21:29:42 +02:00
|
|
|
|
2020-05-04 18:13:57 +02:00
|
|
|
router
|
2020-06-18 17:59:31 +02:00
|
|
|
.get("/api/users", authorized(LIST_USERS), controller.fetch)
|
|
|
|
.get("/api/users/:username", authorized(USER_MANAGEMENT), controller.find)
|
2020-06-26 11:05:09 +02:00
|
|
|
.put("/api/users/", authorized(USER_MANAGEMENT), controller.update)
|
2020-10-07 18:56:47 +02:00
|
|
|
.post("/api/users", authorized(USER_MANAGEMENT), usage, controller.create)
|
2020-05-21 15:31:23 +02:00
|
|
|
.delete(
|
2020-06-18 17:59:31 +02:00
|
|
|
"/api/users/:username",
|
2020-05-21 15:31:23 +02:00
|
|
|
authorized(USER_MANAGEMENT),
|
2020-10-07 18:56:47 +02:00
|
|
|
usage,
|
2020-05-21 15:31:23 +02:00
|
|
|
controller.destroy
|
|
|
|
)
|
2020-04-29 21:29:42 +02:00
|
|
|
|
2020-05-07 11:53:34 +02:00
|
|
|
module.exports = router
|