vadimbakaev / car-seller

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The Car Seller

Codacy Badge

The service allows users to place new car adverts and view, modify and delete existing car adverts.

Installing / Getting started

First off all you need to install MongoDB. Follow the manual with the instruction: https://docs.mongodb.com/manual/administration/install-community/

Once MongoDB installed, run it using the following command:

sudo mongod

By default, MongoDB starts on port 27017.

Run

To run all test and generate coverage report run:

clean coverage test it:test coverageReport coverageAggregate

To start application use:

run

Docker

docker build -t car-sellar .

docker run --rm --name mongo -d  --hostname mongo --expose 27017 mongo
docker run --rm --name car-sellar -it -p 9000:9000 car-sellar

List of available endpoints:

  • POST /public/v1/adverts
  • PUT /public/v1/adverts
  • GET /public/v1/adverts/:id
  • DELETE /public/v1/adverts/:id
  • GET /public/v1/adverts

add car advert

curl --request POST \
  --url http://localhost:9000/public/v1/adverts \
  --header 'content-type: application/json' \
  --data '{
	"id": "18f126d7-708b-4640-83f2-7916b9ad0531",
	"title": "Audi A3 Avant",
	"fuel": "D",
	"price": 7000,
	"new": true,
	"mileage": 70000
}'

get car advert

curl --request GET \
  --url http://localhost:9000/public/v1/adverts/18f126d7-708b-4640-83f2-7916b9ad0531

update car advert

curl --request PUT \
  --url http://localhost:9000/public/v1/adverts \
  --header 'content-type: application/json' \
  --data '{
	"id": "18f126d7-708b-4640-83f2-7916b9ad0531",
	"title": "Opel Manta",
	"fuel": "D",
	"price": 3500,
	"new": true
}'

get all car adverts

curl --request GET \
  --url 'http://localhost:9000/public/v1/adverts?sort=new&desc=true'\

delete car advert

curl --request DELETE \
  --url http://localhost:9000/public/v1/adverts/18f126d7-708b-4640-83f2-7916b9ad0531

About


Languages

Language:Scala 99.7%Language:Dockerfile 0.3%