This project is for the Advanced Full-Stack Web Development track provided by Udacity.
It is a service to resize images with the desired dimensions and save them as a cache to be reused upon request again.
- Server
- Node
- Express
- Sharp
- Development
- Typescript
- Eslint
- Prettier
- Jasmine
- Supertest
Clone the project
git clone https://github.com/Eslam-Gaber645/-Udacity--Image-processing-API.git
Go to the project directory
cd ./-Udacity--Image-processing-API
Install dependencies
npm i
Build project
npm run build
To run the server, run the following command
npm run start
Now the server is running on port 3000!.
To run tests, run the following command
npm run test
Task | Action | Note |
---|---|---|
clean |
Remove build directory | . |
build |
Build the app | uses the clean tasks. |
start |
Start the server | You have to build the app first. |
start:dev |
Start the dev server | . |
jasmine |
Run jasmine tests | You have to build the app first. |
test |
Build app and run tests | uses the build task. |
prettier |
Prettify source code | . |
lint |
Linting source code | . |
lint:fix |
Linting and fix source code | . |
GET /
GET /image?filename=${imageName}&width=${width}&height=${height}
Parameter | Type | Description |
---|---|---|
imageName |
string |
Required. Target image name |
width |
integer |
Optional. Pixel numeric value |
height |
integer |
Optional. Pixel numeric value |
You can change the following environment variables in .env file.
-
PORT
: The server port. -
ORIGINAL_IMAGES_DIR
: The original images directory. -
THUMB_IMAGES_DIR
: The resized images directory.
-If width and height are not defined or are not valid values, then the original image will be sent without resizing.
-If only width or height is defined with a valid value, the other dimension of the image will be scaled based on the aspect ratio of the original image.
-You can resize any image with any extension.