Catherinesjkim / mc-7-be

My copy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Back-End

Schema

Users

Field Type Notes
id integer primary key and autoincrements
email string required and unique
password string required
username string required
role string required

Strains

Field Type Notes
id integer primary key and autoincrements
name string required; name of the strain
image_URL string product image
type text type of strain: Indica, Sativa, Hybrid
description text required; description of the cannabis strains, background, etc.
taste text flavor of the product
effects text different effects obtained
rating string rating from 1 to 5 stars

API

BASE URL: https://mc-7-be.herokuapp.com

test account:

{
  "email": "tester@email.com",
  "password": "test",
  "username": "test123",
  "role": "patient"
}

Table of Contents

Type Path Notes Example
POST /api/auth/register register a new user link
POST /api/auth/login login an user link
 
GET /api/user/:user_id get user info; requires authorization link
PUT /api/user/:user_id update user info; requires authorization link
DELETE /api/user/:user_id delete a user account; requires authorization link
 
GET /api/strains get strains link
POST /api/strains create a new product post; requires name and description link
GET /api/strains/:strain_id get a strain link
PUT /api/strains/:strain_id update a strain; change liked key to like or unlike a submitted product; requires authorization; link
DELETE /api/strains/:strain_id delete a product; requires authorization; link

Examples

POST /api/auth/register

request data:

{
  "email": "username@email.com",
  "password": "password",
  "username": "Name",
  "role": "provider"
}

response data:

{
  "user": {
    "id": 1,
    "email": "username@email.com",
    "username": "Name"
  },
  "authorization": "really.long.token"
}

POST /api/auth/login

request data:

{
  "username": "test123",
  "password": "test"
}

response data:

{
  "user": {
    "id": 1,
    "email": "username@email.com",
    "username": "Name"
  },
  "authorization": "really.long.token"
}

GET /api/users/:user_id

response data

{
  "id": 1,
  "email": "username@email.com",
  "username": "Name",
  "role": "provider"
}

PUT /api/users/:user_id

request data

{
  "email": "username@email.com",
  "username": "Name"
}

response data

{
  "id": 1,
  "email": "username@email.com",
  "username": "Name"
}

DELETE /api/users/:user_id

response data

no content

GET /api/strains/:strain_id

response data

{
  "id": 1,
  "name": "Name of strain",
  "image_URL": "image.com",
  "type": "Type of strain", 
  "description": "About the product text",
  "taste": "Taste of smoke",
  "effects": "Different effects obtained",
  "rating": 1
}

PUT /api/strains/:strain_id

request data

{
  "name": "Name of strain",
  "image_URL": "image.com",
  "type": "Type of strain", 
  "description": "About the strain text",
  "taste": "Taste of smoke",
  "effects": "Different effects obtained",
  "rating": 1
}

response data

{
  "id": 1,
  "name": "Name of strain",
  "image_URL": "image.com",
  "type": "Type of strain", 
  "description": "About the strain text",
  "taste": "Taste of smoke",
  "effects": "Different effects obtained",
  "rating": 1
}

DELETE /api/strains/:strain_id

response data

no content

GET /api/strains

response data

[
  {
    "id": 1,
    "name": "Name of strain",
    "image_URL": "image.com",
    "type": "Type of strain", 
    "description": "About the strain text",
    "taste": "Taste of smoke",
    "effects": "Different effects obtained",
    "rating": 1
  },
  {
    "id": 2,
    "name": "Name of strain",
    "image_URL": "image.com",
    "type": "Type of strain", 
    "description": "About the strain text",
    "taste": "Taste of banana",
    "effects": "Different effects obtained",
    "rating": 2
  }
]

POST /api/strains

request data

{
  "name": "Name of strain",
  "image_URL": "image.com",
  "type": "Type of strain", 
  "description": "About the strain text",
  "taste": "Taste of smoke",
  "effects": "Different effects obtained",
  "rating": 3
}

response data

{
  "id": 1,
  "name": "Name",
  "image_URL": "image.com",
  "type": "Type of strain", 
  "description": "About the strain text",
  "taste": "Taste of smoke",
  "effects": "Different effects obtained",
  "rating": 1
}

GET /api/stories/:product_id

response data

{
  "id": 1,
  "name": "Name",
  "image_URL": "image.com",
  "type": "Type of strain", 
  "description": "About the strain text",
  "taste": "Taste of smoke",
  "effects": "Different effects obtained",
  "rating": 1
}

About

My copy

License:MIT License


Languages

Language:JavaScript 100.0%