Backend of todo app project for Appcent Challenge Project with jwt auth, password encoding and unit testing.
App is deployed on Heroku and ready to use.
Root url of project is
All REST API endpoint documentations can be found at Swagger-ui.
If you wish to read swagger documentation on Swagger online editor just copy Swagger json response and paste it to online editor.
If you try app on heroku, first time loading app will take some time (5-6 secs) because of heroku. So please be patient.
There is 2 options when building the app
-
Download, clone or pull github repository.
-
Open project using your favorite IDE (Intellij IDEA used in this project).
-
Maven should automatically install dependencies.
-
If you want to change any properties go to application.properties
-
Your app is now ready to next step Running App.
-
You need to have docker installed on your computer or server for this option.
-
Run docker pull command to get docker image from Docker-Hub.
docker pull glaxier0/appcent-todo-app
- After image pulled from Docker Hub check images using
docker images
- If image is showing there you are ready to next step Running App.
There is 29 test case you can test them all with following maven command.
mvn clean test
If build app from Github repository option selected use this maven command
mvn spring-boot:run
Or run TodoApplication.java manually from your IDE.
If build app from Docker Hub option selected use this docker command
docker run -dp 8080:8080 glaxier0/appcent-todo-app
after docker run command check if image is running by
docker ps
if docker image is shown there, you successfully started app using docker image.
After running app locally you can check avaible endpoints by adding /swagger-ui/index.html to end of your base url.
There are 2 enpoints that doesnt require Authentication: /users/register and /users/login
- Users should first make a register request to /users/register endpoint
- After registering now make a login request to /users/login endpoint
- If tried with correct credentials login request should return jwt token.
- Now you can use all endpoints with that jwt token
- All you have to do is add "Authorization" header a value like this "Bearer {your_token}"
All REST API endpoint documentations can be found at Swagger-ui.
- First download collection.
- After downloading go to the postman and click import button in left up corner.
- Select downloaded file and import as collection.
- Now in the right up corner select "No enviroment" then click eye icon next to it.
- Click add button enviroment button and name it Todo(Production).
- Add a new variable with name url and paste "https://glaxier-todo.herokuapp.com" exactly this to initial value.
- If initial value and current value is "https://glaxier-todo.herokuapp.com/" like this delete last "/" .
- it should be exactly like this "https://glaxier-todo.herokuapp.com" without "/" after .com
- Click save button in the right up corner.
- Now in the left side extend Todo App collection and click Create User > Authorization > Type > No Auth and save it.
- Now click Login User > Authorization > Type > No Auth and save it.
- In login User > Tests copy and paste below code.
if (pm.response.code === 200) {
pm.environment.set('authToken', pm.response.json().token)
}
- In Todo App collection click every request (except "Create User" and "Login User") and change their Authorization > Type > Bearer Token
- Now Postman setup is done and you can test API using postman
- All you have to do is check required params to the every request from Swagger-ui.
- Then make requests with required params.
- Open Swagger-ui.
- First thing to to is make a post request to /users/register.
- Click try it out and make a valid user.
- Now make a login request to /users/login
- Click try it out and make a login request with same email and password with register request
- If you tried login request with correct credentials it should return 200 with token field.
- Copy token value in response.
- Now click Authorize button or click any lock icon in the right side of requests.
- Paste token value to value and click authorize.
- Now you can make requests to all endpoints.
- /users/logout and /users/logoutAll deletes jwt tokens attached to users.
- If you make request to these 2 endpoints you have to login again and get a new token.