post.route.ts 709 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, fileInfoCtrl } 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.createFileAndPost);
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
router.route("/files/:postId").get(authCtrl.requireLogin, postCtrl.getFiles);

// router.param("postId", postCtrl.userByPostId);
Lee Soobeom's avatar
Lee Soobeom committed
12
13
14
router
  .route("/:postId")
  .post(authCtrl.requireLogin, postCtrl.addCounts)
Lee Soobeom's avatar
Lee Soobeom committed
15
  .get(authCtrl.requireLogin, postCtrl.getOnePost)
Lee Soobeom's avatar
Lee Soobeom committed
16
  .delete(authCtrl.requireLogin, postCtrl.deleteOnePost) // +authenticate
Lee Soobeom's avatar
Lee Soobeom committed
17
  .put(authCtrl.requireLogin, postCtrl.updatePost);
Lee Soobeom's avatar
Lee Soobeom committed
18
19

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