Skip to content

API Routes

Bill Adams edited this page Apr 30, 2021 · 6 revisions

API-Routes

This webapp uses the following API routes to dynamically update the page to create a single-page-app-like feel for the user for specific features

Front-end routes

Home

  • A logged out user will be shown a short list of recipes and prompted to log in when they try to take actions that need authorization

    • GET /api/
  • A logged in user will be shown a larger list of recipes and be able to click on buttons that redirect them to specific actions or display requested information

    • GET /api/

Log in

  • A logged out user will be shown a form to enter their credentials to log in
    • GET /api/login

Sign up

  • An unregistered user can access a sign up page to create a new account
    • GET /api/signup

Profile

  • A user will be able to view their information and make changes to certain details
    • GET /api/users:id

Recipes

  • A logged out user will be prompted to either log in or register with the site, a demo user button will be shown to provide full functionality. Once authenticated, a user will be shown a list of recipes and given options to choose from

    • GET /api/recipes
  • A logged in user will be able to see specific recipes to view, review and add to their recipes boxes

    • GET /api/recipes/:id to view recipes
  • A logged in user will be able to create a new recipe using a form and see it added to the site's database

    • GET /api/recipes/create to render a form for recipe creation
    • POST /api/recipes/create to create new recipe entity in the database
  • A logged in user will be able to edit a recipe they created using a form on the site

    • PUT /api/recipes:id

Recipe Boxes

  • A logged in user will be shown a collection of their recipe boxes and a truncated list of recipe titles contained therein
    • GET /api/recipe-boxes
  • A logged in user will be able to view a specific recipe box with forms to remove recipes or edit information about their recipe boxes
    • GET /api/recipe-boxes/:id

Back-end routes(?)

Recipes

  • A logged in user may delete one of their own recipes, removing it from the list of visible recipes without causing a refresh/redirect
    • DELETE /api/recipes/:id
  • A logged in user may create a recipe, adding it to the list of recipes available on the site
    • POST /api/recipes/
  • A logged in user may get recipes from the database, rending x(to be decided later) at a time, then retrieving and rendering more as the user scrolls down
    • GET /api/recipes
  • A logged in user may edit one of their own recipes, changing it inside the database
    • PUT /api/recipes/:id

Reviews

  • A logged in user may delete one of their own reviews, removing it from the list of visible reviews on a specific recipe without causing a refresh/redirect
    • DELETE /api/reviews/:id
  • A logged in user may write a review, adding it to the list of reviews for the given recipe
    • POST /api/reviews/
  • A logged in user will see reviews from the database for a particular recipe while they are viewing it
    • GET /api/reviews/:recipeid
  • A logged in user may edit one of their own reviews, changing it inside the database
    • PUT /api/reviews/:id

Users

  • A new user will be able to create their own user account, allowing them to log in and access more features
    • POST /api/users
  • A registered user will be able to log in to their account, gaining access to restricted features
    • (GET?) /api/user:id?