Skip to content

Commit

Permalink
Modify: remove next functions in controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
Jun4928 committed Dec 31, 2020
1 parent 82927c9 commit 07e45a0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions controllers/ArticleController.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ const { ArticleService } = require('../services')
const { errorWrapper, errorGenerator } = require('../errors')
const { validateFields } = require('../utils')

const getArticles = errorWrapper(async (req, res, next) => {
const getArticles = errorWrapper(async (req, res) => {
const articles = await ArticleService.findArticles(req.query)
res.status(200).json({ articles })
})

const getOneArticle = errorWrapper(async (req, res, next) => {
const getOneArticle = errorWrapper(async (req, res) => {
const { articleId } = req.params
const article = await ArticleService.findArticle({ id: articleId })

Expand All @@ -16,7 +16,7 @@ const getOneArticle = errorWrapper(async (req, res, next) => {
res.status(200).json({ article })
})

const postOneArticle = errorWrapper(async (req, res, next) => {
const postOneArticle = errorWrapper(async (req, res) => {
const { id: userId } = req.foundUser
const { title, body } = req.body

Expand All @@ -31,7 +31,7 @@ const postOneArticle = errorWrapper(async (req, res, next) => {
res.status(201).json({ createdArticle })
})

const updateOneArticle = errorWrapper(async (req, res, next) => {
const updateOneArticle = errorWrapper(async (req, res) => {
const { id: userIdFromToken } = req.foundUser
const { articleId } = req.params
const requestedFields = req.body
Expand All @@ -55,7 +55,7 @@ const updateOneArticle = errorWrapper(async (req, res, next) => {
res.status(201).json({ updatedArticle })
})

const publishOneArticle = errorWrapper(async (req, res, next) => {
const publishOneArticle = errorWrapper(async (req, res) => {
const { id: userIdFromToken } = req.foundUser
const { articleId } = req.params

Expand All @@ -71,7 +71,7 @@ const publishOneArticle = errorWrapper(async (req, res, next) => {
res.status(201).json({ publishedArticle })
})

const deleteOneArticle = errorWrapper(async (req, res, next) => {
const deleteOneArticle = errorWrapper(async (req, res) => {
const { id: userIdFromToken } = req.foundUser
const { articleId } = req.params

Expand Down
8 changes: 4 additions & 4 deletions controllers/CommentController.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const { CommentService } = require('../services')
const { errorWrapper, errorGenerator } = require('../errors')

const getComments = errorWrapper(async (req, res, next) => {
const getComments = errorWrapper(async (req, res) => {
const { articleId } = req.params

const comments = await CommentService.fetchComments({ article_id: Number(articleId) })
res.status(200).json({ comments })
})

const postComment = errorWrapper(async (req, res, next) => {
const postComment = errorWrapper(async (req, res) => {
const { articleId } = req.params
const { id: userIdFromToken } = req.foundUser
const { body } = req.body
Expand All @@ -22,7 +22,7 @@ const postComment = errorWrapper(async (req, res, next) => {
res.status(201).json({ createdComment })
})

const updateComment = errorWrapper(async (req, res, next) => {
const updateComment = errorWrapper(async (req, res) => {
const { articleId, commentId } = req.params
const { body } = req.body
const { id: userIdFromToken } = req.foundUser
Expand All @@ -43,7 +43,7 @@ const updateComment = errorWrapper(async (req, res, next) => {
res.status(200).json({ updatedComment })
})

const deleteComment = errorWrapper(async (req, res, next) => {
const deleteComment = errorWrapper(async (req, res) => {
const { articleId, commentId } = req.params
const { id: userIdFromToken } = req.foundUser

Expand Down
4 changes: 2 additions & 2 deletions controllers/UserController.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const jwt = require('jsonwebtoken')
const { UserService } = require('../services')
const { errorWrapper, errorGenerator } = require('../errors')

const signUp = errorWrapper(async (req, res, next) => {
const signUp = errorWrapper(async (req, res) => {
const { email, password } = req.body
if (!email || !password) errorGenerator({ statusCode: 400, message: 'invalid input' })

Expand All @@ -25,7 +25,7 @@ const signUp = errorWrapper(async (req, res, next) => {
})
})

const logIn = errorWrapper(async (req, res, next) => {
const logIn = errorWrapper(async (req, res) => {
const { email, password: inputPassword } = req.body

const foundUser = await UserService.findUser({ email })
Expand Down

0 comments on commit 07e45a0

Please sign in to comment.