Skip to content

4th semester. Final project on the subject of REST-oriented web services.

Notifications You must be signed in to change notification settings

gitEugeneL/REST-web-services-final-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

REST-web-services-final-project

4th semester. Final project on the subject of REST-oriented web services.

This is a prototype auction, which consists of 3 independent REST servers and databases.

Each server is written in spring boot and uses MongoDB.

The project also has a web interface using vue.js. The web interface is for demonstration only.


How to run MongoDBs.

Each server has its own database. The container must be run separately for each server.

1.Build Docker images based on the configuration defined in the docker-compose.yml

docker-compose build

2.Download Docker images for all services defined in the docker-compose.yml

docker-compose pull

3.Start containers and run composition for all services defined in the docker-compose.yml

docker-compose up -d

How to run Spring boot servers

https://docs.spring.io/spring-boot/docs/1.5.16.RELEASE/reference/html/using-boot-running-your-application.html

How to run Vue.js web client

1.Project Setup

npm install

2.Compile and Hot-Reload for Development

npm run dev

How to connect to servers and web client

Authentication server Application server Payment server Web client app
Base URL http://localhost
app ports 8080 8081 8082 3000
DB ports 27017 27018 27019 -

How to run stripe locally to test payments

1.Install the Stripe CLI

https://stripe.com/docs/stripe-cli#install

2.Login in to the CLI

https://stripe.com/docs/stripe-cli#login-account

3.Start webhook listener in terminal

stripe listen --forward-to=localhost:8082/api/payment/webhook

Authentication Server

Login

POST /api/user/login(allows to login, issues a bearer token)
Parameters
name type data type
login required string
password required string
Responses
http code content-type response
200 application/json {"type": "Bearer", "accessToken": "eyJhbGciOi..........."}
401 application/json {"status": "UNAUTHORIZED", "message": "email or password is not valid"}

Logout (token required)

GET /api/user/logout(allows to logout, deactivates the token)
Parameters

None

Responses
http code content-type response
200 text/plain;charset=UTF-8 "User logged out successfully"
401 application/json {"status": "UNAUTHORIZED", "message": "token is not valid"}

Create user

POST /api/user/create(allows to create an account)
Parameters
name type data type
login required string
password required string
firstName required string
lastName required string
Responses
http code content-type response
200 text/plain;charset=UTF-8 "user added successfully"
400 application/json {"status": "BAD_REQUEST", "message": "firstName: must not be empty........"
400 application/json {"status": "BAD_REQUEST", "message": "User already exists"

Get users (token required)

GET /api/user(find all active users)
Parameters

None

Responses
http code content-type response
200 application/json [{"id": "645e5414830e393ff09ce411", "email": "user1@gmail.com","firstName": "user1","lastName": "user1"}, ]
401 application/json {"status": "UNAUTHORIZED", "message": "token is not valid"}

Get one user (token required)

GET /api/user/{ userId }(find one active user by id)
Parameters

None

Responses
http code content-type response
200 application/json {"id": "645e5414830e393ff09ce411", "email": "user1@gmail.com","firstName": "user1","lastName": "user1"}
400 application/json {"status": "BAD_REQUEST", "message": "User not found for id: 214e1423..."}
401 application/json {"status": "UNAUTHORIZED", "message": "token is not valid"}

Get authorized user (token required)

GET /api/user/auth/info(get only this authorized user)
Parameters

None

Responses
http code content-type response
200 application/json {"id": "645e5414830e393ff09ce411", "email": "user1@gmail.com","firstName": "user1","lastName": "user1"}
400 application/json {"status": "BAD_REQUEST", "message": "User does not exist"
401 application/json {"status": "UNAUTHORIZED", "message": "token is not valid"}

Update authorized user (token required)

PUT /api/user(update only this authorized user)
Parameters
name type data type
firstName required string
lastName required string
Responses
http code content-type response
200 text/plain;charset=UTF-8 "User successfully changed"
400 application/json {"status": "BAD_REQUEST", "message": "firstName: must not be empty........"
401 application/json {"status": "UNAUTHORIZED", "message": "User is not authorized to update this profile"}
401 application/json {"status": "UNAUTHORIZED", "message": "token is not valid"}

Delete authorized user (token required)

DELETE /api/user(delete only this authorized user)
Parameters

None

Responses
http code content-type response
200 text/plain;charset=UTF-8 "User successfully deleted"
401 application/json {"status": "UNAUTHORIZED", "message": "User is not authorized to delete this profile"}
401 application/json {"status": "UNAUTHORIZED", "message": "token is not valid"}

Application Server

Create a new auction lot (token required)

POST /api/auction/create(allows to create a new auction lot)
Parameters
name type data type
name required string
description required string
startingPrise int string
lifeTime required string ("test" OR "one-day" OR "three-days" OR "one-week" )
Responses
http code content-type response
200 text/plain;charset=UTF-8 "645e5414830e393ff09ce411"
400 application/json {"status": "BAD_REQUEST", "message": "description: must not be empty........"
400 application/json {"status": "BAD_REQUEST", "message": "An active lot with this name already exists"
401 application/json {"status": "UNAUTHORIZED", "message": "Auth integration exception"}

Upload an image for the auction lot (token required) (image required)

POST /api/image/upload/{ auctionId }(allows to attach an image to your auction)
Parameters

None

Responses
http code content-type response
200 text/plain;charset=UTF-8 "645e5414830e393ff09ce411"
400 application/json {"status": "BAD_REQUEST", "message": "Image already exist"
401 application/json {"status": "UNAUTHORIZED", "message": "Auth integration exception"}

Get an image for the auction lot (token required)

GET /api/image/download/{ auctionId }(allows you to get an auction image)
Parameters

None

Responses
http code content-type response
200 image/png image file
400 application/json {"status": "BAD_REQUEST", "message": "Image not found"
401 application/json {"status": "UNAUTHORIZED", "message": "Auth integration exception"}

Update the auction lot (token required)

PUT /api/auction/{ auctionId }(allows an authorized user to update their auction)
Parameters
name type data type
description required string
Responses
http code content-type response
200 text/plain;charset=UTF-8 "Auction id: 645e5414830e393ff09ce411 successfully changed"
400 application/json {"status": "BAD_REQUEST", "message": "description: must not be empty........"
400 application/json {"status": "BAD_REQUEST", "message": "Auction not found for id: 645e5414830e393ff09ce411"
401 application/json {"status": "UNAUTHORIZED", "message": "User is not authorized to update this auction"}
401 application/json {"status": "UNAUTHORIZED", "message": "Auth integration exception"}

Delete an authorized user's auction (token required)

DELETE /api/user(allows an authorized user to delete his lot if there aren't participants)
Parameters

None

Responses
http code content-type response
200 text/plain;charset=UTF-8 "Auction id: 645e5414830e393ff09ce411 successfully deleted"
400 application/json {"status": "BAD_REQUEST", "message": "You can't delete an auction that has participants"
400 application/json {"status": "BAD_REQUEST", "message": "Auction not found for id: 645e5414830e393ff09ce411"
401 application/json {"status": "UNAUTHORIZED", "message": "User is not authorized to delete this auction"}
401 application/json {"status": "UNAUTHORIZED", "message": "Auth integration exception"}

Place a bet (token required)

POST /api/user(allows to place a bet)
Parameters
name type data type
auctionId required string
bet required int
http code content-type response
200 text/plain;charset=UTF-8 "The new bet has been created successfully"
400 application/json {"status": "BAD_REQUEST", "message": "bet: must not be empty........"
400 application/json {"status": "BAD_REQUEST", "message": "User is trying to buy his product"
400 application/json {"status": "BAD_REQUEST", "message": "The auction is outdated"
400 application/json {"status": "BAD_REQUEST", "message": "The bet is less than the current price"
400 application/json {"status": "BAD_REQUEST", "message": "Auction lot not fount for id: 645e5414830e393ff09ce411"
401 application/json {"status": "UNAUTHORIZED", "message": "Auth integration exception"}

Get active auction lots (token required)

GET /api/auction(find all active auction lots)
Parameters

None

Responses
http code content-type response
200 application/json [{"id": "645fa196aa3af742845525bb", "sellerEmail": "test2@gmail.com","sellerName": "test2", "status": "ACTIVE", "participation": {"645e5414830e393ff09ce411": 546,}, "name": "testauction", "description": "testauction", "starting_price": 100, "current_price": 546, "end_time": "2023-06-20T14:41:26.021Z", "winnerId": nul}, ]
401 application/json {"status": "UNAUTHORIZED", "message": "Auth integration exception"}

Get auctions that were created by an authorized user (token required)

GET /api/auction/auth-user-auctions(find all auction lots that were created by an authorized user)
Parameters

None

Responses
http code content-type response
200 application/json [{"id": "645fa196aa3af742845525bb", "sellerEmail": "test2@gmail.com","sellerName": "test2", "status": "ACTIVE", "participation": {"645e5414830e393ff09ce411": 546,}, "name": "testauction", "description": "testauction", "starting_price": 100, "current_price": 546, "end_time": "2023-06-20T14:41:26.021Z", "winnerId": nul}, ]
401 application/json {"status": "UNAUTHORIZED", "message": "Auth integration exception"}

Get auctions that were created by an authorized user (token required)

GET /api/auction/auth-participant-auctions(find all active auctions in which the authorized user participates)
Parameters

None

Responses
http code content-type response
200 application/json [{"id": "645fa196aa3af742845525bb", "sellerEmail": "test2@gmail.com","sellerName": "test2", "status": "ACTIVE", "participation": {"645e5414830e393ff09ce411": 546,}, "name": "testauction", "description": "testauction", "starting_price": 100, "current_price": 546, "end_time": "2023-06-20T14:41:26.021Z", "winnerId": nul}, ]
401 application/json {"status": "UNAUTHORIZED", "message": "Auth integration exception"}

Get finished auctions, where the authorized user is winner (token required)

GET /api/auction/auth-winner-auctions(find all finished auctions, where the authorized user is winner)
Parameters

None

Responses
http code content-type response
200 application/json [{"id": "645fa196aa3af742845525bb", "sellerEmail": "test2@gmail.com","sellerName": "test2", "status": "FINISHED", "participation": {"645e5414830e393ff09ce411": 546,}, "name": "testauction", "description": "testauction", "starting_price": 100, "current_price": 546, "end_time": "2023-04-20T14:41:26.021Z", "winnerId": "645e5414830e393ff09ce411"}, ]
401 application/json {"status": "UNAUTHORIZED", "message": "Auth integration exception"}

Get auctions paid for by an authorized user (token required)

GET /api/auction/auth-purchased-auctions(find all auctions paid for by an authorized user)
Parameters

None

Responses
http code content-type response
200 application/json [{"id": "645fa196aa3af742845525bb", "sellerEmail": "test2@gmail.com","sellerName": "test2", "status": "PAID", "participation": {"645e5414830e393ff09ce411": 546,}, "name": "testauction", "description": "testauction", "starting_price": 100, "current_price": 546, "end_time": "2023-04-20T14:41:26.021Z", "winnerId": "645e5414830e393ff09ce411"}, ]
401 application/json {"status": "UNAUTHORIZED", "message": "Auth integration exception"}

Get one auction lot (token required)

GET /api/auction/{ auctionId }(find one auction lot by id)
Parameters

None

Responses
http code content-type response
200 application/json {"id": "645fa196aa3af742845525bb", "sellerEmail": "test2@gmail.com","sellerName": "test2", "status": "ACTIVE", "participation": {"645e5414830e393ff09ce411": 546,}, "name": "testauction", "description": "testauction", "starting_price": 100, "current_price": 546, "end_time": "2023-06-20T14:41:26.021Z", "winnerId": nul}
401 application/json {"status": "UNAUTHORIZED", "message": "Auth integration exception"}

Payment Server

Initial payment (token required)

GET /api/payment/{ auctionId }(initial payment)
Parameters

None

Responses
http code content-type response
200 text/plain;charset=UTF-8 "https://stripe.com/....."
401 application/json {"status": "UNAUTHORIZED", "message": "Auction integration exception"}
401 application/json {"status": "UNAUTHORIZED", "message": "Auth integration exception"}

Stripe validate webhook (token required)

GET /api/payment/webhookwebhook for validate payment

https://stripe.com/docs/api/webhook_endpoints

Links