REST API to perform CRUD operations on a DB of Cat Images
$ npm install
Download and start MongoDB Community Edition as a service on your system (https://www.mongodb.com/try/download/community). This is a pre-requisite to running the application and must be done before running the npm run start command.
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
# unit tests
$ npm run test
# test coverage
$ npm run test:cov
To see Swagger docs open this URL
The Add New Image operation is on the default route of '/cats' and takes a jpeg file as input, returning an Cat object with the Id and path properties.
We shall use this Id for all operations needing it for the request.
The Download All Images operation is on the route '/downloadAll', returning a zip file containing all the images currently in the DB that downloads to the users system on API response.
The List ALl Cats opeation is on the route '/listAll', returning a JSON array containing all the Cat objects in the DB (as defined in the POST Operation).
The Get Image By Id operation is on the route '/cats/{id}' and takes an Id path param as input, returning the file corresponding to the Id from the DB to be downloaded on the users system.
The Replace Image operation is on the route '/cats/{id}' and takes a jpeg file and an Id as input, replacing the image with the given Id by the new image provided as the input file.
The Cat object of the new image is returned as the response. Note: The Id remains the same, only the path changes as per RFC-6902
The Delete Image operation is on the route '/cats/{id}' and takes an Id path param, deleting the image from the DB and returning a 204 - NO CONTENT
status code.
The Sign Up operation is on the route '/auth/signup' and takes a username and password as input, adds the new user in the data DB with a hashed password.
Returns a User object containing the username and password(hashed) of the user.
The Log In operation is on the route '/auth/login' and takes username and password as input.
Returning a JSON object with the access_token property to be used by the user as the Bearer Token for access to the '/cats' routes.