2020-05-07 21:53:34 +12:00
|
|
|
const Router = require("@koa/router")
|
|
|
|
const controller = require("../controllers/user")
|
2020-05-22 01:31:23 +12:00
|
|
|
const authorized = require("../../middleware/authorized")
|
|
|
|
const { USER_MANAGEMENT, LIST_USERS } = require("../../utilities/accessLevels")
|
2020-04-30 07:29:42 +12:00
|
|
|
|
2020-05-07 21:53:34 +12:00
|
|
|
const router = Router()
|
2020-04-30 07:29:42 +12:00
|
|
|
|
2020-05-05 04:13:57 +12:00
|
|
|
router
|
2020-06-19 03:59:31 +12:00
|
|
|
.get("/api/users", authorized(LIST_USERS), controller.fetch)
|
|
|
|
.get("/api/users/:username", authorized(USER_MANAGEMENT), controller.find)
|
2020-06-26 21:05:09 +12:00
|
|
|
.put("/api/users/", authorized(USER_MANAGEMENT), controller.update)
|
2020-06-19 03:59:31 +12:00
|
|
|
.post("/api/users", authorized(USER_MANAGEMENT), controller.create)
|
2020-05-22 01:31:23 +12:00
|
|
|
.delete(
|
2020-06-19 03:59:31 +12:00
|
|
|
"/api/users/:username",
|
2020-05-22 01:31:23 +12:00
|
|
|
authorized(USER_MANAGEMENT),
|
|
|
|
controller.destroy
|
|
|
|
)
|
2020-04-30 07:29:42 +12:00
|
|
|
|
2020-05-07 21:53:34 +12:00
|
|
|
module.exports = router
|