Skip to content

A basic CRUD API using Spring Boot with MongoDB. The application will contain user management and product management functionalities.

Notifications You must be signed in to change notification settings

ManWhoSoldTheW0rld/letsplay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot & MongoDB REST API

A basic CRUD API using Spring Boot with MongoDB. The application will contain user management and product management functionalities.

Prerequisites

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>

Getting Started

  1. Clone this repository:

    git clone [email protected]:ManWhoSoldTheW0rld/letsplay.git
    
  2. Change to the project directory:

    cd letsplay
  3. Configure MongoDB connection in src/main/resources/application.properties:

  4. Build and run the application:

    ./gradlew bootRun
  5. The application will be accessible at [https://localhost:8443/].

API Endpoints

Registration and Authentication

  • 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

Products

  • 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>
}

Users

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>
   }

License

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.

About

A basic CRUD API using Spring Boot with MongoDB. The application will contain user management and product management functionalities.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages