API for product management. Built in Spring Boot with MongoDB.
In order to run the project, you should set the environment variables.
databaseUrl=YourDatabaseUrl; databaseName=YourDatabaseName; databaseUsername=YourDatabaseUsername; databasePassword=YourDatabasePassword
The image could be deployed using the follwing commands
docker build -t products-api .docker run --env databaseUrl=YourDatabaseUrl --env databaseName=YourDatabaseName --env databaseUsername=YourDatabaseUsername --env databasePassword=YourDatabasePassword -p 8080:8080 products-apiDocumentation about endpoints could be found in Swagger
The /authenticate endpoint return a JWT for you use other endpoints. For every endpoint you should pass the token in header. KEY=authorization VALUES=Bearer {token}
{
"username": "admin",
"password": "password"
}Add new product in database. With there is an product with same name, a HTTP Code 409 (CONFLICT) will return.
{
"name": "string",
"description": "string",
"price": 0
}Update product's name. With there is an product with same name, a HTTP Code 409 (CONFLICT) will return. The id should be pass in path. eg. http://localhost:8080/v1/products/a1b2c3d4
{
"productName": "string"
}Delete a product from database. The id should be pass in path. eg. http://localhost:8080/v1/products/a1b2c3d4
Return a product from database. The id should be pass in path. eg. http://localhost:8080/v1/products/byId/a1b2c3d4
Return a product from database. The name should be pass in path. eg. http://localhost:8080/v1/products/byName/productName
Return all products from database sorted by products name.