Skip to content

saksham-sharma/crud-ops-nest

Repository files navigation

Cat REST API

Description

REST API to perform CRUD operations on a DB of Cat Images

Installation

$ npm install

Running the app

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

Test

# unit tests
$ npm run test

# test coverage
$ npm run test:cov

Swagger Docs

To see Swagger docs open this URL

CRUD Operation Documentation

ADD NEW IMAGE(POST)

        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.

DOWNLOAD ALL IMAGES(GET)

        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.

LIST ALL CATS(GET)

        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).

GET IMAGE BY ID(GET)

        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.

REPLACE IMAGE(PUT)

        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

DELTE IMAGE(DELTE)

        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.

SIGN UP(POST)

        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.

LOG IN(POST)

        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.

About

CRUD Ops with Nest.JS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published