Skip to content

matheusfenolio/products-api

Repository files navigation

Products Management API

API for product management. Built in Spring Boot with MongoDB.

TESTS and BUILD

Environment variables

In order to run the project, you should set the environment variables.

databaseUrl=YourDatabaseUrl; databaseName=YourDatabaseName; databaseUsername=YourDatabaseUsername; databasePassword=YourDatabasePassword

Docker

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

Swagger

Documentation about endpoints could be found in Swagger

Endpoints

/authenticate

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

/v1/products

POST

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
}

PUT

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

Delete a product from database. The id should be pass in path. eg. http://localhost:8080/v1/products/a1b2c3d4

/v1/products/byId

GET

Return a product from database. The id should be pass in path. eg. http://localhost:8080/v1/products/byId/a1b2c3d4

/v1/products/byName

GET

Return a product from database. The name should be pass in path. eg. http://localhost:8080/v1/products/byName/productName

/v1/products/all

GET

Return all products from database sorted by products name.

About

API for manage products. Created for a test

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published