post.route.ts 606 Bytes
Newer Older
Lee Soobeom's avatar
Lee Soobeom committed
1
import express from "express";
Lee Soobeom's avatar
Lee Soobeom committed
2
import { postCtrl, authCtrl } from "../controllers";
Lee Soobeom's avatar
Lee Soobeom committed
3
4
5

const router = express.Router();

Lee Soobeom's avatar
Lee Soobeom committed
6
router.route("/").post(authCtrl.requireLogin, postCtrl.postCreate);
Lee Soobeom's avatar
Lee Soobeom committed
7
router.route("/").get(postCtrl.getAllPost);
Lee Soobeom's avatar
Lee Soobeom committed
8

Lee Soobeom's avatar
Lee Soobeom committed
9
10
11
12
13
14
15
16
17
18
router
  .route("/:postId")
  .post(authCtrl.requireLogin, postCtrl.addCounts)
  .get(authCtrl.requireLogin, postCtrl.getOnePost);

router.route("/:postId").delete(authCtrl.requireLogin, postCtrl.deleteOnePost); // authenticate

router.route("/:postId").put(authCtrl.requireLogin, postCtrl.updatePost);

router.param("postId", postCtrl.userByPostId);
Lee Soobeom's avatar
Lee Soobeom committed
19
export default router;