Skip to content

WaterMyPlants2/Backend-Java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

Backend-Java

Table of contents

Overview

Water My Plants

Ensuring that all your plants are consistently watered is actually pretty difficult. Water My Plants is an app that helps to solve those problems.

With an easy to use interface for creating a plant watering schedule tailored to each individual plant, WaterMyPlants will remind users when it's time to feed that foliage and quench your plants' thirst.

API endpoints

⬆ Belows are only some basic endpoints, check out for more endpoints ⬆

Authentication

Method Endpoint Body (required) Comments Notes
register POST /api/auth/register username, password, phonenumber Creates a new user in the database.
login POST /api/auth/login username, password axios.post('https://jren-watermyplants.herokuapp.com/api/auth/login', <br>'grant_type=password&username=${form.username}&password=${form.password}', {<br>headers: <br>{'Basic ${btoa('lambda-client:lambda-secret')},<br>'Content-Type': 'application/x-www-form-urlencoded}) Returns a access token. (res.data.access_token)
logout GET /api/auth/logout AxiosWithAuth (required) Revokes the token of current user

➡ To access endpoints for users and plants, MUST include a request header as follows ⬅

For GET, DELETE: headers: {Authorization: 'Bearer ${token}'} For POST, PUT, PATCH : headers: {Authorization: 'Bearer ${token}', Content-type: 'application/json'}

EndPoints for Users

Method Endpoint Body (required) Comments Notes
get current user info GET /api/users/info Returns info of current user
update user PUT /api/users/:id username, password, phonenumber Updates the user with user id
delete user DELETE /api/users/:id Deletes the user with user id

Endpoints for Plants

Method Endpoint Body (required) Comments Notes
get plants GET /api/plants Fetches all plants of current user
add plant POST /api/plants nickname, species, h2ofrequency, image add plant to current user's plants
update plant PUT /api/plants/:id nickname, species, h2ofrequency, image Update plant with plant id
delete plant by Id DELETE /api/plants/:id Delete Plant by Id