Skip to content

πŸŒπŸ’­πŸ§™β€β™‚οΈ Implemented a REST API that manages quotes, while supporting different CRUD operations.

Notifications You must be signed in to change notification settings

mansstiv/Quotes-Rest-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Quotes-Rest-API

Implemented a REST API that manages quotes.

Tech Stack

Part 1: Implementation

A quote has the following fields:

  • author (string): The name of the author of the quote (optional).
    • e.g. 'Oscar Wilde'
  • text (string): The text of the quote (mandatory).
    • e.g. 'The truth is rarely pure and never simple.'

The API supports the following operations.

  • Create a quote:
    • /quotes, method=POST
    • Fields of quote should be provided in body of request in a json format.
  • Update a quote with a specific ID:
    • /quotes/<id>, method=PUT
    • Fields of quote should be provided in body of request in a json format.
  • Get a quote with a specific ID:
    • /quotes/<id>, method=GET
  • Delete a quote with a specific ID:
    • /quotes/<id>, method=DELETE
  • Get a random quote:
    • /quotes/random, method=GET
  • Get all quotes:
    • /quotes, method=GET
  • Get quotes that contain specific text (e.g. "discover"):
    • /quotes/substring, method=GET
    • Substring of quote should be provided as a value in body of request in a json format. Name of key can be anything you want.

(id in endpoint is the object id generated automatically in the field '_id')

Part 2: Testing

Tested with pytest endpoints that create, update and return a quote.

Part 3: Containerization

Wrote Dockerfile for the application.

Wrote a Compose file to define and run the application as a set of containers (one container for the application, one container for the database).

Used Docker and Docker Compose.

Part 4: Running

# create and start (the first run takes time to build the image)
docker-compose up

# stop/restart
docker-compose stop
docker-compose start

# stop and remove
docker-compose down -v

# run tests
docker-compose run app python app_test.py

About

πŸŒπŸ’­πŸ§™β€β™‚οΈ Implemented a REST API that manages quotes, while supporting different CRUD operations.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published