Create an image processing API that resizes and saves images to user specifications when visiting a URL, and caches out data if it already exists. this project is submitted for Advanced Full-Stack Web Development Nanodegree by udacity.
Install required packages
npm install
to build the application and compile TS to JS
npm run build
to start the server in production/build
npm run start
to start the server in dev
npm run start-dev
to run tests
npm run test
to run lint and prettier
npm run lint
npm run prettier
localhost
http://localhost:3000/
/api/images
http://localhost:3000/api/images?filename=name&width=number&height=number
For example,
http://localhost:3000/api/images?filename=fjord&width=500&height=400
the endpoint takes 3 query parameters
- filename=name, where name must be a string of length > 0
- width=number, where width must be postive integer greater than 0
- height=number, where height must be postive integer greater than 0
-
image must be in images folder to be resized
-
to resize fjord.jpg image placed in images folder with width=500 and height=400, example below
http://localhost:3000/api/images?filename=fjord&width=500&height=400
- the resized images will be placed in resizedImages folder with file name
filename_width_height.jpg
fjord_500_400.jpg
- if the image already exists in resizedImage, it will be cached out without reprocessing.
I used express-validator to validate query parameters and make sure that
- filename exists in images folder, if not return a 400 status code with error message.
- width and height are positive integers and greater than 0, if not return a 400 status code with error message.
- express and express-validator
- fs and path
- jasmine and supertest
- prettier and lint
- typescript