Skip to content
Walter Hills edited this page Jan 29, 2021 · 2 revisions

GET /

  • Renders login.pug template containing login form
  • form action: '/login'
  • form method: 'POST'

GET /signup

  • Renders signup.pug template containing registration form
  • form action: '/users'
  • form method: 'POST'

POST /

  • creates a new user
  • logs user in
  • redirects to '/profile'

GET /logout

  • logs the user out
  • redirects to '/'

GET /profile

  • Renders profile.pug
  • template variables needed: user(object containing information about user), posts(posts that will be filtered by userId)

GET /home

  • Renders index.pug
  • template variables needed: posts (array of posts from users)

GET /posts/new

  • Renders new-post.pug template containing form to create a new post
  • form action: '/posts'
  • form method: 'POST'

POST /posts/new

  • creates a new post
  • redirects to posts/pid(pid is id of newly created post)

GET /posts/search

  • renders index.pug template showing posts with only posts matching either category from drop down or from search term in search bar.

GET /posts/:pid

  • render post.pug
  • template variables needed: post (include post comments)

DELETE /posts/:pid

  • delete post with :id
  • redirects to /home

POST /api/posts/:pid/comments

  • creates a new comment with postId === req.params.id
  • route will be hit when a user submits the comment form for post

DELETE /api/posts/:pid/comments/:cid

  • delete comment with :cid on post with :pid
  • route will be hit when a user hits the delete button on their comment