Coder Social home page Coder Social logo

image-api's Introduction

Resize Images API

This application has the scope of serving images with the option of resizing. The API has two endpoints.

Resize Image Endpoint

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.

Statistics Endpoint

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

Running instructions

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

Docker instructions

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

image-api's People

Contributors

mboghi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.