Skip to content

KshitijBharde/image-upload-server

Repository files navigation

Cat Image Upload Server

Welcome to the Cat Image Upload Server repository! This repository hosts a NestJS server that provides APIs to manage and interact with a collection of adorable cat images. You can easily deploy this server using Docker for a hassle-free setup.

Table of Contents

Prerequisites

  • Node.js (version >= 16.X.X)
  • npm (version >= 9.X.X)
  • Docker (version >= 24.X.X)
  • Docker Compose (version =< 1.29.1)

Before running the server, create a .env file in the root directory based on the provided .env.example file. This file contains configuration options for the server, including the port to use. Modify the values in the .env file to match your preferences.

Getting Started

Running Locally

  1. Clone this repository:
git clone https://github.com/KshitijBharde/image-upload-server.git
cd image-upload-server
  1. Install dependencies:
npm install
  1. Start the server:
npm run start:dev

The server will be accessible at http://localhost:[SERVER_PORT].

The swagger doc will be accessible at http://localhost:[SERVER_PORT]/doc.

Docker Deployment

  1. Run a container with Docker Compose:
docker-compose -f docker-compose.yml up -d

The server will be accessible at http://localhost:[SERVER_PORT].

API Documentation

Add a New Cat

Endpoint: POST /cats/addNewCat

Request:

  • Headers:
    • Content-Type: application/json
  • Body:
    • name: string (required)
    • age: number

Response:

  • Status: 200 OK
  • Status: 400 Bad Request (for invalid requests)

Add New Images to a Cat

Endpoint: POST /cats/addNewCatImages/:catId

Request:

  • Headers:
    • Content-Type: multipart/form-data
  • Params:
    • catId: number (required)
  • Body:
    • files: array of image files

Response:

  • Status: 200 OK
  • Status: 400 Bad Request (for invalid requests)

Delete a Cat

Endpoint: DELETE /cats/deleteCatById/:catId

Request:

  • Params:
    • catId: number (required)

Response:

  • Status: 200 OK
  • Status: 400 Bad Request (for invalid requests)

Delete a Cat Image

Endpoint: DELETE /cats/deleteCatImageById/:catImageId

Request:

  • Params:
    • catImageId: number (required)

Response:

  • Status: 200 OK
  • Status: 400 Bad Request (for invalid requests)

Update a Cat

Endpoint: PUT /cats/updateCat

Request:

  • Body:
    • id: number (required)
    • name: string (required)
    • age: number

Response:

  • Status: 200 OK
  • Status: 400 Bad Request (for invalid requests)

Update a Cat Image

Endpoint: PUT /cats/updateCatImageById/:catImageId

Request:

  • Headers:
    • Content-Type: multipart/form-data
  • Params:
    • catImageId: number (required)
  • Body:
    • file: image file

Response:

  • Status: 200 OK
  • Status: 400 Bad Request (for invalid requests)

List Cat Images

Endpoint: GET /cats/listCatImages

Request:

  • Params:
    • limit: number (optional)
    • offset: number (optional)

Response:

  • Status: 200 OK
  • Status: 400 Bad Request (for invalid requests)

List Cats

Endpoint: GET /cats/listCats

Request:

  • Params:
    • limit: number (optional)
    • offset: number (optional)

Response:

  • Status: 200 OK
  • Status: 400 Bad Request (for invalid requests)

Download Cat Image

Endpoint: GET /cats/downloadCatImageById/:catImageId

Request:

  • Params:
    • catImageId: number (required)

Response:

  • Image download response

About

A Nestjs server which exposes APIs for uploading images

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published