Skip to content

API Documentation & Routes

nathanieldcooke edited this page Jan 2, 2022 · 18 revisions

This website uses the following API routes to dynamically update the page.

Profile

  • POST /api/users/signup - A user can create (i.e. sign up) a new account.

    • Request JSON:
      {
        username: (string),
        email: (string),
        password: (string),
        confirmPassword: (string)
      }
    • Response JSON:
      {
        status: (boolean),
        errors: (string[]),
        user: { 
                id: (number), 
                username: (string)
              }
      }
  • PUT /api/users/demo - A user can use a demo profile to experience the website.

    • Request JSON:
      {
        // No data required for request body
      }
    • Response JSON:
      {
        status: (boolean),
        errors: (string[]),
        user: { 
                id: (number), 
                username: (string)
              }
      }
  • PUT /api/users/login - A user can update (i.e. log in) the session.

    • Request JSON:
      {
        credential: (string),
        password: (string)
      }
    • Response JSON:
      {
        status: (boolean),
        errors: (string[]),
        user: { 
                id: (number), 
                username: (string)
              }
      }
  • PUT /api/users/logout - A user can update (i.e. log out) the session.

    • Request JSON:
      {
        // No data required for request body
      }
    • Response JSON:
      {
        status: (boolean),
        errors: (string[]),
        user: { 
                id: (null), 
                username: (null)
              }
      }
  • GET /api/users/profile - A user can restore prior active session.

    • Request JSON:
      {
        // No data required for request body
      }
    • Response JSON:
      {
        status: (boolean),
        errors: (string[]),
        user: { 
                id: (number|null), 
                username: (string|null)
              }
      }

Bookmarks

  • PUT /api/users/:userId/bookmarks/:projectId - A user can add projects to their bookmarks.

    • Request JSON:
      {
        bookmarked: (boolean)
      }
    • Response JSON:
      {
        projectId: (number)
      }
  • GET /api/users/:userId/bookmarks/page/:pageNumber - A user can view projects in their bookmarks.

    • Request JSON:
      {
        // No data required for request body
      }
    • Response JSON:
      {
        projects: (IProjects[])
      }

Projects

  • GET /api/projects/:category/page/:pageNumber - A user can view projects.

    • Request JSON:
      {
        // No data required for request body
      }
    • Response JSON:
      {
        projects: (IProjects[])
      }
  • GET /api/projects/:projectId - A user can view a specific project and its details.

    • Request JSON:
      {
        // No data required for request body
      }
    • Response JSON:
      {
        project: (IProject)
      }
  • DELETE /api/users/:userId/hide-project/:projectId - A user can delete the visibility of a project.

    • Request JSON:
      {
        // No data required for request body
      }
    • Response JSON:
      {
        message: 'success'
      }

Contributions

  • POST /api/users/:userId/contributions - A user can contribute to projects.

    • Request JSON:
      {
        supportTierId: (number),
        amountPledged: (number),
        curr_url: (string)
      }
    • Response JSON:
      {
        url: (string)
      }
  • GET /api/users/:userId/contributions/page/:pageNumber - A user can view their contributions and the related projects.

    • Request JSON:
      {
        // No data required for request body
      }
    • Response JSON:
      {
        contributions: ({
          receiptTile:IReceipt, 
          projectTile:IProjects
        }[])
      }

Typescript Interfaces used in JSON

IProjects = {
   id:number
   screenShot:string
   title:string
   summary:string
   imgAlt:string
   creatorName:string
   percentFunded:number
   pageNums:number
   bookmarked:boolean
}
IProject = {
   id:number
   goal:number|null
   screenShot:string|undefined
   imgAlt:string|null
   videoSrc:string|undefined
   title:string|null
   summary:string|null
   creatorName:string|null
   fundsCollected:number|null
   percentFunded:number
   numOfBackers:number
   supportTiers:ISupportTier[]
   daysToGo:number
   bookmarked:boolean
}
IReceipt = {
   amountPledged:number|null
   nameOfTier:string|null
   summaryOfTier:string|null
   etaDelivery:string|null
   shipsTo:string|null
}
Clone this wiki locally