This application has the scope of serving images with the option of resizing. The API has two endpoints.
Endpoint relative path is /image/image_name.extension?size=(width)x(height) It can be called without the size query option.
Images are taken from a pre-defined folder on the disk and can be added during aplication execution. There is a cache mechanism that will keep on disk each resized image and serve it when required a second time. The cache cleans up automatically each 60 seconds, by deleting the resized images that have not been called since the last cleanup.
Endpoint relative path is /stats Endpoint will return this info about the cache:
- number of hits vs misses (hits/misses)
- number of original images
- number of resized images
The default source path for loadin the images is \images, relative to the root path. It can be changed before running the app in /src/util/path.ts
For running the API, after cloning the repository, you can run these commands:
- npm run build
- npm run dev
The application will be runing at this link http://localhost:3000
To build the docker image use command: docker build -t image-api .
To run the docker image use command: docker run -d --name image-api -p 8080:3000 image-api Service will be available at link http://localhost:8080/
To stop the container run command: docker stop image-api To delete the container run command: docker rm image-api