/backendapi

backend-database

Primary LanguageJavaScript

backendAPI

Documentation

Base URL for deployed API: https://funding-platform-bw.herokuapp.com

Endpoints

Method URL Description Requires Token Requires Admin
POST /api/auth/register register a new user - -
POST /api/auth/login login as existing user - -
POST /api/ create a new project X -
GET /api/projects get information of all projects X -
GET /api/projects/:id gets a specific project by id X -
PUT /api/projects/:id edit a project X X
DELETE /api/projects/:id delete a project from database X X

Table Requirements

Fundraiser (Users)

Name Type Required Unique Notes
id integer yes yes auto generated by the API
firstname string yes yes -
lastname string yes yes -
password string yes no -
role boolean no no 0 or 1 is the same as false and true, you can use either

Project

Request and Return

POST /api/auth/register

---Request Body

{
    "firstname": "Evie",
    "lastname": "Levie",
    "password": "passwords"
}

---Return

{
    "message": "Welcome! Your account sucessfully registered",
    "data": {
        "user_id": 25,
        "firstname": "Evie",
        "lastname": "Levie",
        "password": "$2a$08$Zvy5EH/BKN28kspTTkzLyeS6ikjuoKBA8NRgCNIHGGHWyF8HvnP1q",
        "role": 0
    },
}

POST /api/auth/login

---Request body

{
    "firstname": "Evie",
    "lastname": "Levie",
    "password": "passwords"
}

--- Return

{
    "message": "Welcome, it's Virtual Reality Funding Platform ",
    "user": {
        "user_id": 22,
        "firstname": "Evie",
        "lastname": "Levie",
        "password": "$2a$08$98dK8S27AlD4/IxC8QhPTezhbeEzY2hgjVd2zS6gr0Ui.aItaeaH2"
    },
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoyMiwiZmlyc3RuYW1lIjoiRXZpZSIsImxhc3RuYW1lIjoiTGV2aWUiLCJpYXQiOjE2MDMwNDg5NTMsImV4cCI6MTYwMzA5MjE1M30.Z8AlXbDQ55g2eGkys0NJ0m-5FTy700qwlGCx_JRcs1k"
}

PROJECT DB ENDPOINT

GET /api/projects

--- Request

Headers

| Key |         |                 Value                          |
|Authorization| | eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.    eyJyb2xlIjoyMiwiZmlyc3RuYW1lIjoiRXZpZSIsImxhc3RuYW1lIjoiTGV2aWUiLCJpYXQiOjE2MDMwNDg5NTMsImV4cCI6MTYwMzA5MjE1M30.Z8AlXbDQ55g2eGkys0NJ0m-5FTy700qwlGCx_JRcs1k |

--- Return

[
    {
        "id": 1,
        "project_name": "Astro App - Translate Sign Language ",
        "project_founder": "Astrofolic",
        "project_description": "What do you write in a Astro project description",
        "project_goal": 10000.00
    },
    {
        "id": 2,
        "project_name": "Stark App - Healthcare",
        "project_founder": "Molasses",
        "project_description": "What do you write in  Stark project description",
        "project_goal": 20000.00
    },
    {
        "id": 3,
        "project_name": "Skyhawks App - Virtual Assistant ",
        "project_founder": "Dexstrose",
        "project_description": "What do you write in  Skyhawks project description",
        "project_goal": 3000.00
    },
    {
        "id": 4,
        "project_name": "Project X App - Travel Vision ",
        "project_founder": "Iron",
        "project_description": "What do you write in Project X  project description",
        "project_goal": 3500.00
    },
    {
        "id": 5,
        "project_name": "Cascade App- Virtual Shopping",
        "project_founder": "Benja",
        "project_description": "What do you write in Cascade project description ",
        "project_goal": 4000.00
    }
]

GET /api/projects/:id

--- Request

Headers

| Key |         |                 Value                          |
|Authorization| | 'valid token here' |

--- Return

{
    "message": "This is information of project with specific ID",
    "project": {
        "id": 4,
        "project_id": 4,
        "project_name": "Project X App - Travel Vision ",
        "project_founder": "Iron",
        "project_description": "What do you write in Project X  project description",
        "project_goal": "$35,00.00"
    }
}

POST/api/projects

---Request

   {
        "id": 6 ,
        "project_name": "Anything",
        "project_founder": "Anyone",
        "project_description": "What do you write in YADAYADA project description Test",
        "project_goal": 5800.00
    }

---Return

  {
        "id": 6 ,
        "project_name": "Anything",
        "project_founder": "Anyone",
        "project_description": "What do you write in YADAYADA project description Test",
        "project_goal": 5800.00
    }

DELETE/api/projects (...is updating)

---Request

https://funding-platform-bw.herokuapp.com/api/projects/1

---Return

{
    "error": 500,
    "err": {}
}

FUNDING DATABASE ENDPOINT

GET/api/funding

---Return

{
"message": "This is funding information",
"res": [
{
"id": 1,
"project_id": 1,
"project_name": "Astro App - Translate Sign Language ",
"project_description": "What do you write in a Astro project description",
"project_raised": "26700.00"
},
{
"id": 2,
"project_id": 2,
"project_name": "Stark App - Healthcare",
"project_description": "What do you write in  Stark project description",
"project_raised": "564500.00"
},
{
"id": 3,
"project_id": 3,
"project_name": "Skyhawks App - Virtual Assistant ",
"project_description": "What do you write in  Skyhawks project description",
"project_raised": "6234.00"
},
{
"id": 4,
"project_id": 4,
"project_name": "Project X App - Travel Vision ",
"project_description": "What do you write in Project X  project description",
"project_raised": "731400.00"
},
{
"id": 5,
"project_id": 5,
"project_name": "Cascade App- Virtual Shopping",
"project_description": "What do you write in Cascade project description ",
"project_raised": "828500.00"
}
]
}

GET/api/funding/:id

---Request

https://funding-platform-bw.herokuapp.com/funding/1

---Return

{
    "success": "Project information is updated",
    "id": 1,
    "project_id": 1,
    "project_name": "Astro App - Translate Sign Language Editted ",
    "project_description": "What do you write in a Astro project description",
    "project_raised": 30000,
    "UpdatingInformation": 1
}
 

PUT/api/funding/:id

---Request

{
"id": 1,
"project_name": "Astro App - Translate Sign Language Editted ",
"project_description": "What do you write in a Astro project description",
"project_raised": 30000
}

---Return

{
    "success": "Project information is updated",
    "id": 1,
    "project_name": "Astro App - Translate Sign Language Editted ",
    "project_description": "What do you write in a Astro project description",
    "project_raised": 30000,
    "UpdatingInformation": 1
}

Database skeleton :

projects = [   {
      id: 1,
      project_name: "Astro App - Translate Sign Language ",
      project_founder: "Astrofolic",
      project_description: "What do you write in a Astro project description",
      project_goal: 10000.00
    },
]

funding = [
    {
      id: 1,
      project_name: "Astro App - Translate Sign Language ",
      project_description: "What do you write in a Astro project description",
      project_raised: 2670.00
    }
 ]

  const users = [
    {
      firstname: "",
      lastname: "",
      password:"",
      role: 1,
    },
  ];