BASE URL https://node-server-med-cabinet.herokuapp.com
Authentication Routes | Recommendation Routes | Strain Routes | Helper Routes
Creates a new user account. Returns an object with user info and a JSON web token.
Input:
{
email: "example@email.com", // string (required)
password: "abc123!", // string (required)
first_name: "firstname", // string (required)
last_name: "lastname" // string (required)
}
Output:
{
user: {
id: 1,
email: "example@email.com",
first_name: "firstname",
last_name: "lastname"
},
token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6OSwicm9sZV9pZCI6MSwiaWF0IjoxNTc3MTY1MDY3LCJleHAiOjE1NzcxNjg2Njd9.pg1rqfKM5BxyLssMVyL8xrCW9BjKZhmqIrODlZp16Kk"
}
Validates user credentials. Returns an object with user info and a JSON web token.
Input:
{
email: "example@email.com", // string (required)
password: "abc123!", // string (required)
}
Output:
{
message: "Welcome ${user.first_name}!",
credentials: {
user: {
id: 1,
email: "example@email.com",
first_name: "firstname",
last_name: "lastname"
},
token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiaWF0IjoxNTc4NDE4NzY1LCJleHAiOjE1Nzg1MDUxNjV9.VIoyWSOLYiNKJR4araMaZxzAX-10fJzTsAu1NL-R0UE"
}
}
Returns an array of user recommended strains and the user id.
Request:
/api/user/1/recommendation
Response:
[
{
user_id: 1,
strain_id: 7
},
{
user_id: 1,
strain_id: 8
},
{
user_id: 1,
strain_id: 9
},
...
]
Adds a strain to the user's recommendations. Returns a success message and an object listing the user id and strain id.
Request:
/api/user/1/recommendation
Input:
{
strain_id: 7 // integer (required)
}
Output:
{
message: "Blueberry Dream added",
recommendations: {
user_id: 1,
strain_id: 7
}
}
Removes recommended strain by strain id.
Request:
/api/user/1/recommendation/2
Response:
{
message: "Recommendation removed"
}
URL: https://node-server-med-cabinet.herokuapp.com/api/strains
Returns an array of all strains in the database.
Request:
// No input needed
Response:
[
{
id: 1,
strain: "Ak-47"
},
{
id: 2,
strain: "Afghani"
},
{
id: 3,
strain: "Alohaberry"
},
...
]
Creates a new strain in the database.
Input:
{
strain: "Purple Kush" // string (required)
}
Output:
[
{
id: 1,
strain: "Purple Kush"
}
]
Updates user account information
Request:
/api/user/1
Input:
{
email: "example@email.com" // string (required)
}
// or
{
password: "abc123!"
}
// or
{
first_name: "firstname"
}
...
Output:
{
message: "User has been updated",
user: [
{
id: 1,
email: "example@email.com",
password: "abc123!",
first_name: "firstname",
last_name: "lastname"
}
]