FP5: Express Router

Charlie·2021년 1월 2일
0

First Project

목록 보기
5/8
post-thumbnail
  • Express
  • Express Router
// 'users.js' from 'routes' Directory
const express = require('express');
const router = express.Router();
const { usersController } = require('../controllers');

router.post('/register', usersController.register.post);
router.post('/login', usersController.login.post);
router.post('/logout', usersController.logout.post);
router.get('/accessTokenRequest', usersController.accessTokenRequest.get);
router.get('/refreshTokenRequest', usersController.refreshTokenRequest.get);
router.get('/mypage/read', usersController.mypage.get);
router.put('/mypage/update', usersController.mypage.put);

module.exports = router;
// 'posts.js' from 'routes' Directory
const express = require('express');
const router = express.Router();
const {postsController} = require('../controllers');

router.post('/create', postsController.create.post);
router.get('/read', postsController.read.getPosts);
router.get('/user/read', postsController.read.getUserPosts);
router.get('/:id/read', postsController.read.getPost);
router.get('/search', postsController.search.get);
router.get('/:id/tags/read', postsController.tags.get);
router.put('/:id/update', postsController.update.put);
router.delete('/:id/remove', postsController.remove.delete);

module.exports = router;
// 'comments.js' from 'routes' Directory
const express = require('express');
const router = express.Router();
const { commentsController } = require('../controllers');

router.post('/create', commentsController.create.post);
router.get('/post/:postId/read', commentsController.read.getComment);
router.get('/:id/read', commentsController.read.getComments);
router.put('/:id/update', commentsController.update.put);
router.delete('/:id/remove', commentsController.remove.delete);

module.exports = router;

0개의 댓글