A basic CRUD API using Spring Boot with MongoDB. The application will contain user management and product management functionalities.
- Java Development Kit (JDK) 17 or higher installed
- [MongoDB] You can you local or cloud version
To install local version of mongodb on Mac you can use homebrew:
# Enter the latest version instead of <mongodb-community>
brew tap mongodb/brew
brew install <mongodb-community>
brew services start <mongodb-community>
#To stop service run
brew services stop <mongodb-community>
-
Clone this repository:
git clone [email protected]:ManWhoSoldTheW0rld/letsplay.git
-
Change to the project directory:
cd letsplay
-
Configure MongoDB connection in
src/main/resources/application.properties
: -
Build and run the application:
./gradlew bootRun
-
The application will be accessible at [https://localhost:8443/].
- POST /api/v1/auth/register
with JSON raw Body
{
"name": <name>,
"email": <email>,
"password": <password>,
"role" : <USER|ADMIN>
}
Responds with a valid JWT
- POST /api/v1/auth/authenticate
with JSON raw Body
{
"email": <email>,
"password": <password>,
}
Responds with a valid JWT
- GET /api/v1/product/list : Returns list of products
- GET /api/v1/product/item/ : Returns product with info
For requests below JWT authorization required
- POST /api/v1/product/ : Adds a new product
- PUT /api/v1/product/ : Updates product with
- DELETE /api/v1/product/ : Deletes product with
For adding and updating product request should contain JSON raw Body
{
"name": <name>,
"price" : <price>,
"description" : <description>
}
For requests below JWT authorization required
- GET /api/v1/user/list : Returns list of users
- GET /api/v1/user/ : Returns user with info
For requests below JWT authorization required
- PUT /api/v1/user/ : Updates user with
- DELETE /api/v1/user/ : Deletes user with
For updating user request should contain JSON raw Body
{
"name": <name>,
"email": <email>,
"password": <password>,
"role" : <USER|ADMIN>
}
This project is licensed under the MIT License - see the LICENSE file for details.
You can copy and paste this updated template into your README.md file on GitHub. Don't forget to replace <username>
, <password>
, <host>
, and <database>
in the MongoDB connection string with your actual MongoDB credentials and database information.