This project follows the Clean code Architecture
.
The Logic implementation
for the various use-cases
can be found in the use-cases
folder which is inside the src
folder. e.g /src/use-cases
.
The Controllers are in the /src/controllers
folder.
The project code base tends to implement Functional Programming
as its programming paradigm.
- Make sure you have Node.js and MongoDB installed locally on your machine.
- Run
npm install
to install the necessary packages. - To start up the server, simply type
npm start
from your terminal. Make suremongodb
is running locally.
The API does the following
- You can upload images
- You can crop, resize, and rotate images
- You can export images to
JPG
,PNG
, andPDF
-
To upload an image, make a
POST
request tohttp://localhost:5000/api/v1/image/upload
. You can usePOSTMAN
to upload the image file, through theform-data
body and the respective key name isfilename
. The uploaded file is available in theuploads
folder which can be viewed in the project root directory e.grootDir/uploads
-
To crop an image, make a
PATCH
request tohttp://localhost:5000/api/v1/image/crop/:id
where theid
is the id of the image. The required query parameters arewidth
,height
,x
, andy
. These values are numbers. The cropped image can be found in theuploads
folder which have a filename format of the following nature1234949-image.jpg
-
To resize an image, make a
PATCH
request tohttp://localhost:5000/api/v1/image/resize/:id
where theid
is the id of the image. The required query parameters arewidth
, andheight
. These values are numbers. The resized image can be found in theuploads
folder which have a filename format of the following nature1234949-image.jpg
-
To rotate an image, make a
PATCH
request tohttp://localhost:5000/api/v1/image/rotate/:id
where theid
is the id of the image. The required query parameters isdeg
. which specifies the degree of rotation. This value is a number. The rotated image can be found in theuploads
folder which have a filename format of the following nature1234949-image.jpg
- To export the image to either
JPEG
,PNG
andPDF
, simply make a make aPOST
request tohttp://localhost:5000/api/v1/image/export/:id
where theid
is the id of the image. The required query parameter isimageType
.imageType
can either bepng
,jpg
orpdf
. The exported images can be viewed in theuploads
folder in the project root directory e.grootDir/uploads
. The generated pdf file can be viewed in thepdf
folder directory which is also in the root project directory e.grootDir/pdf
.