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.
- 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.
- Clone this repository:
git clone https://github.com/KshitijBharde/image-upload-server.git
cd image-upload-server
- Install dependencies:
npm install
- 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
.
- Run a container with Docker Compose:
docker-compose -f docker-compose.yml up -d
The server will be accessible at http://localhost:[SERVER_PORT]
.
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)
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)
Endpoint: DELETE /cats/deleteCatById/:catId
Request:
- Params:
- catId: number (required)
Response:
- Status: 200 OK
- Status: 400 Bad Request (for invalid requests)
Endpoint: DELETE /cats/deleteCatImageById/:catImageId
Request:
- Params:
- catImageId: number (required)
Response:
- Status: 200 OK
- Status: 400 Bad Request (for invalid requests)
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)
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)
Endpoint: GET /cats/listCatImages
Request:
- Params:
- limit: number (optional)
- offset: number (optional)
Response:
- Status: 200 OK
- Status: 400 Bad Request (for invalid requests)
Endpoint: GET /cats/listCats
Request:
- Params:
- limit: number (optional)
- offset: number (optional)
Response:
- Status: 200 OK
- Status: 400 Bad Request (for invalid requests)
Endpoint: GET /cats/downloadCatImageById/:catImageId
Request:
- Params:
- catImageId: number (required)
Response:
- Image download response