GithubHelp home page GithubHelp logo

build-week-med-cabinet-4 / back-end Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 8.24 MB

๐Ÿ”‘ Backend to the medical marijuana recommendation website hosting user information and connected to Data Science Strain API

License: MIT License

JavaScript 100.00%
javascript backend routing database user-information web-development

back-end's Introduction

Back-End Documentation

Under Construction!

Note: Many endpoints in this API return an array of objects for ease-of-mapping in the front end. This is a convenience feature that might not always be available depending on how the data we want to send is structured. In the case that you should receive an object of objects, go ahead and use Object.values(thingToConvert) to convert it to an array of objects.

Note 2 electric boogaloo: The /responses endpoints have COMPLETELY CHANGED! Be sure to read these docs thoroughly!

Things We, The Back-End, Need To Do

  • Find out -EXACTLY- what recommendations are. What they contain and belong to, etc.
    • A recommendation is:
         {
             ??????????
         }
      
  • Find out what responses are as well. Relations and stuff.
    • A response is:
      {
          "strain": "sham-wow"
      }
      
  • Get It Hosted (oh boy)

Endpoints:

Auth

POST to /api/auth/register:

API request data shape FROM front-end:

{
    "username": "your-username-here",
    "password": "super-secret-thing-SHHHhHHHSSh",
    "full_name": "Insert Your Seventy-Five Surnames Here",
    "email": "[email protected]"
}

If successful, the API will respond with the newly created user:

{
    "id": 1298347, //This can really be any integer, but it increments.
    "username": "your-username-here",
    "password": "super-secret-thing-SHHHhHHHSSh",
    "full_name": "Insert Your Seventy-Five Surnames Here",
    "email": "[email protected]"
}

POST to /api/auth/login:

What the front-end should be sending to API:

{
    "username": "zoinks",
    "password": "scoob"
}

The API will respond with a token on login success:

{
    token: "secret cow says moo", //This will be a string of garbledygook. Send this in your authentication header whenever you want to access something restricted as the front-end.
    message: "Welcome, zoinks!"
}

Responses

POST to /api/responses/search:

Be sure to send a valid token in the Authentication header.

The API accepts an object of parameters that can be empty or string to search with:

{
	"positive_effect": "euphoria",
	"negative_effect": "",
	"medical_effect": "",
	"flavor": "apple",
	"desc": ""
}

And returns an object containing the strain:

{
    "description": "1024 is a sativa-dominant hybrid bred in Spain by Medical Seeds Co. The breeders claim to guard the secret genetics due to security reasons, but regardless of its genetic heritage, 1024 is a THC powerhouse with a sweet and spicy bouquet. Subtle fruit flavors mix with an herbal musk to produce uplifting sativa effects. One specific phenotype is noted for having a pungent odor that fills a room, similar to burning incense.",
    "effects": "Uplifted,Happy,Relaxed,Energetic,Creative",
    "flavor": "Spicy/Herbal,Sage,Woody",
    "id": 2,
    "name": "1024",
    "race": "sativa",
    "rating": 4
}

GET to /api/responses/:id:

Be sure to send a valid token in the Authentication header.

The API accepts a strain_id in the URI and returns an object containing the strain:

{
    "description": "1024 is a sativa-dominant hybrid bred in Spain by Medical Seeds Co. The breeders claim to guard the secret genetics due to security reasons, but regardless of its genetic heritage, 1024 is a THC powerhouse with a sweet and spicy bouquet. Subtle fruit flavors mix with an herbal musk to produce uplifting sativa effects. One specific phenotype is noted for having a pungent odor that fills a room, similar to burning incense.",
    "effects": "Uplifted,Happy,Relaxed,Energetic,Creative",
    "flavor": "Spicy/Herbal,Sage,Woody",
    "id": 2,
    "name": "1024",
    "race": "sativa",
    "rating": 4
}

GET to /api/responses/user/:id:

Be sure to send a valid token in the Authentication header.

The API accepts a user_id in the URI and returns an array of objects containing the strain_ids for that user:

[
    {
        "strain_id": 421
    },
    {
        "strain_id": 68
    }
]

POST to /api/responses:

Shape you want to send to the API:

{
    "strain_id": 419,
    "user_id": 1 
}

POST to /api/responses/delete:

Be sure to send a user_id and a strain_id in the body of your request.

{
    "strain_id": 50,
    "user_id": 51 
}

Basically, what you're doing is telling the API to delete the specified strain from the user's data. But the API needs to know WHICH user you are referring to.

The API is going to return the number of records deleted:

{
    "deleted": 1
}

Same thing as above applies. If this isn't 1, something has gone horribly wrong.

DS Database API stuff (Front-end doesn't need to worry about this).

POST to https://med-cabinet-4-api.herokuapp.com/predict:

{
"positive_effect": "euphoria",
"negative_effect": "DEATH",
"medical_effect": "immortality",
"flavor": "euphoria",
"desc": "euphoria"
}

Response will be:

{
    "description": "Cherry OG by Emerald Triangle Seeds is a hybrid cannabis strain bred by combining Cherry Thai, Afghani, and Lost Coast OG genetics. A 50/50 hybrid, Cherry OG truly brings you the best of both sativa and indica worlds as it delivers full-body euphoria alongside high-flying cerebral lucidity. While its name sets expectations of a fruity cherry aroma, this strain can sometimes express more sour and diesel-like flavors.ย ",
    "effects": "Euphoric,Relaxed,Happy,Uplifted,Hungry",
    "flavor": "Berry,Diesel,Sweet",
    "id": 511,
    "name": "Cherry-Og",
    "race": "hybrid",
    "rating": 4
}

GET to https://med-cabinet-4-api.herokuapp.com/search:

{
    "id": 1-3018
}

Response is same as above.

back-end's People

Contributors

dournbrood avatar georgeraymond98 avatar sage-jordan avatar tylerrussin avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.