This is the repository for the Backend team of WaterMyPlants2
Water My Plants 2
https://water-my-plants-backend-drake.herokuapp.com/
Request | URL | Description |
---|---|---|
POST | /api/auth/register | creates a new user with username, phone number and password |
POST | /api/auth/login | login valid user with username and password |
POST | /api/users/:id/plants | adds plant for a specific user (REQUIRES TOKEN) |
GET | /api/auth/plants | gets an array of all plants for all users |
GET | /api/users | gets an array of all users (REQUIRES TOKEN) |
GET | /api/users/:id | gets user info for a user with given ID (REQUIRES TOKEN) |
GET | /api/users/:id/plants | gets an array of plants for a specific user (REQUIRES TOKEN) |
GET | /api/plants/:id | gets info for a plant with a given ID (REQUIRES TOKEN) |
PUT | /api/users/:id | updates info for a user with a given ID (REQUIRES TOKEN) |
PUT | /api/plants/:id | updates info for a plant with a given ID (REQUIRES TOKEN) |
DELETE | /api/users/:id | deletes a user with a given ID (REQUIRES TOKEN) |
DELETE | /api/plants/:id | deletes a plant with a given ID (REQUIRES TOKEN) |
Name | Type | Required | Unique | Notes |
---|---|---|---|---|
id | integer | yes | yes | users id (auto generated by API) |
username | string | yes | yes | users name |
password | string | yes | no | users password |
phoneNumber | string | yes | yes | users phoneNumber |
Name | Type | Required | Unique | Notes |
---|---|---|---|---|
id | integer | yes | yes | plants id (auto generated by API) |
nickname | string | yes | no | plants nickname |
species | string | yes | no | plants species |
h2oFrequency | string | yes | no | how many times the plants need to be watered (twice a week) |
image | string | no | no | url address for image of that plant (optional) |
user_id | integer | yes | no | user's ID associated with plant - foreign key (will auto populate when a new seed is created) |
{
"username": "jon",
"password": "snow",
"phoneNumber": "123123"
}
{
"newUser": {
"id": 6,
"username": "jon",
"phoneNumber": "123123"
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjYsInVzZXJuYW1lIjoiam9uIiwiaWF0IjoxNTkyOTQ4MjY4LCJleHAiOjE1OTMyMDc0Njh9.3vG0YC7Cf0I-w6IPxnjGkVx0u0wx8dxMCx-7TltDVqk"
}
{
"username": "jon",
"password": "snow"
}
{
"welcome": "jon",
"user_id": 6,
"phoneNumber": "123123",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjYsInVzZXJuYW1lIjoiam9uIiwiaWF0IjoxNTkyOTQ4NjU4LCJleHAiOjE1OTMyMDc4NTh9.kMLo7IG8kmpBx-K948w3Hw7bONsAUkOlrckTerjcX1o"
}
{
"nickname": "Green",
"species": "Mr.Green",
"h2oFrequency": "300 times a week",
"image": "https://images.unsplash.com/photo-1558350315-8aa00e8e4590?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1234&q=80"
}
{
"id": 6,
"nickname": "Green",
"species": "Mr.Green",
"h2oFrequency": "300 times a week",
"image": "https://images.unsplash.com/photo-1558350315-8aa00e8e4590?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1234&q=80",
"user_id": 1
}
[
{
"id": 4,
"species": "Allium genus",
"h2oFrequency": "5 times a week",
"image": "https://images.unsplash.com/photo-1558350315-8aa00e8e4590?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1234&q=80"
},
{
"id": 6,
"species": "Mr.Green",
"h2oFrequency": "300 times a week",
"image": "https://images.unsplash.com/photo-1558350315-8aa00e8e4590?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1234&q=80"
}
]
[
{
"id": 1,
"username": "cat",
"phoneNumber": "676767"
},
{
"id": 2,
"username": "liz",
"phoneNumber": "3232"
},
{
"id": 3,
"username": "mark",
"phoneNumber": "7171"
},
{
"id": 4,
"username": "brian",
"phoneNumber": "56565"
},
{
"id": 6,
"username": "jon",
"phoneNumber": "123123"
}
]
{
"id": 6,
"username": "jon",
"phoneNumber": "123123"
}
[
{
"plant_id": 4,
"nickname": "Allen",
"species": "Allium genus",
"h2oFrequency": "5 times a week",
"image": "https://images.unsplash.com/photo-1558350315-8aa00e8e4590?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1234&q=80",
"user": "cat"
},
{
"plant_id": 6,
"nickname": "Green",
"species": "Mr.Green",
"h2oFrequency": "300 times a week",
"image": "https://images.unsplash.com/photo-1558350315-8aa00e8e4590?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1234&q=80",
"user": "cat"
}
]
{
"id": 6,
"nickname": "Green",
"species": "Mr.Green",
"h2oFrequency": "300 times a week",
"image": "https://images.unsplash.com/photo-1558350315-8aa00e8e4590?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1234&q=80",
"user_id": 1
}
{ "username": "jon",
"password": "stark",
"phoneNumber": "555"
}
{
"id": 6,
"username": "jon",
"phoneNumber": "555"
}
{
"nickname": "Tomato",
"species": "Mr.Red",
"h2oFrequency": "2 times a week",
"image": "https://images.unsplash.com/photo-1558350315-8aa00e8e4590?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1234&q=80"
}
{
"id": 6,
"nickname": "Tomato",
"species": "Mr.Red",
"h2oFrequency": "2 times a week",
"image": "https://images.unsplash.com/photo-1558350315-8aa00e8e4590?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1234&q=80",
"user_id": 1
}
{
"message": "User with ID 6 has been removed"
}
{
"message": "Plant with ID 6 has been removed"
}
# Dependencies Used
"dependencies": {
"bcryptjs": "^2.4.3",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"helmet": "^3.23.1",
"jsonwebtoken": "^8.5.1",
"knex": "^0.21.1",
"cors": "^2.8.5",
"sqlite3": "^4.2.0",
},
"devDependencies": {
"jest": "^24.3.1",
"nodemon": "^1.18.10",
"supertest": "^4.0.0"
}
- Drake Alia