A simple bookstore API server written as an excersice for learning Java.
Download Java and Maven, and set up their path variables
git clone https://github.com/samiulsami/apitest.git
cd apitest
mvn package
java -jar target/apitest-1.0-SNAPSHOT-jar-with-dependencies.jar
method | url | body | actions |
---|---|---|---|
GET | http://localhost:8000/bookstore/login |
--header 'Authorization: Basic c2FtaToxMjM0' | returns a JWT token $TOKEN |
GET | http://localhost:8000/bookstore/books |
--header 'Authorization: Bearer $TOKEN' | returns all books |
GET | http://localhost:8000/bookstore/books/{id} |
--header 'Authorization: Bearer $TOKEN' | returns book with given id |
POST | http://localhost:8000/bookstore/books |
given below | adds a book |
PUT | http://localhost:8000/bookstore/books/{id} |
given below | updates book with given id |
DELETE | http://localhost:8000/bookstore/books/{id} |
--header 'Authorization: Bearer $TOKEN' | deletes book with given id |
curl --location 'http://localhost:8000/bookstore/login' \
--header 'Authorization: Basic c2FtaToxMjM0'
curl --location 'http://localhost:8000/bookstore/books' \
--header 'Authorization: Bearer $TOKEN'
curl --location 'http://localhost:8000/bookstore/books/1' \
--header 'Authorization: Bearer $TOKEN'
curl --location --request POST 'http://localhost:8000/bookstore/books' \
--header 'title: dsad' \
--header 'authorName: askdj' \
--header 'authorID: 123' \
--header 'pages: 111' \
--header 'Authorization: Bearer $TOKEN'
curl --location --request PUT 'http://localhost:8000/bookstore/books/6' \
--header 'title: Cat Cafe' \
--header 'authorName: George Orwell' \
--header 'pages: 140' \
--header 'authorID: 2' \
--header 'Authorization: Bearer $TOKEN'
curl --location --request DELETE 'http://localhost:8000/bookstore/books/5' \
--header 'Authorization: Bearer $TOKEN'
- https://metamug.com/article/security/jwt-java-tutorial-create-verify.html
- https://github.com/metamug/java-jwt/blob/master/src/test/java/com/metamug/jwt/JWebTokenTest.java
- https://medium.com/consulner/framework-less-rest-api-in-java-dd22d4d642fa
- https://github.com/heheh13/api-server
- https://github.com/MobarakHsn/api-server/tree/master
- https://github.com/AbdullahAlShaad/bookstore-api-server
- https://codefresh.io/blog/java_docker_pipeline/
- https://stackoverflow.com/questions/2022032/building-a-runnable-jar-with-maven-2
docker pull sami7786/apitest:1.0
docker build -t sami7786/apitest:1.0 .
docker run -p 8000:8000 sami7786/apitest:1.0
TODO