user.route.ts 497 Bytes
Newer Older
1
import express from "express";
Yoon, Daeki's avatar
Yoon, Daeki committed
2
import { userCtrl, authCtrl, fileCtrl } from "../controllers";
3
4
5
6
7
8

const router = express.Router();

router
  .route("/")
  .get(authCtrl.requireLogin, userCtrl.getUsers)
9
10
11
12
13
14
  .post(
    authCtrl.requireLogin,
    authCtrl.hasRole("admin"),
    fileCtrl.uploadAvatar,
    userCtrl.createUser
  );
15

Yoon, Daeki's avatar
Yoon, Daeki committed
16
17
18
19
20
21
router
  .route("/:userId")
  .delete(authCtrl.requireLogin, authCtrl.authenticate, userCtrl.deleteUser);

router.param("userId", userCtrl.userById);

22
export default router;