Skip to content

GasserKhaled330/Image.Processing.API

Repository files navigation

Image Processing API - Udacity Fullstack JS Nanodegree

Introduction

This is a simple REST API allowing users to create, access and resize placeholder images using the Sharp Node.js image processing module.


Getting Started

Installing dependencies

After cloning the repo, all the project dependencies can be installed using npm:

npm install

Scripts

The following actions can be executed through npm scripts:

Transpiling typescript to javascript

npm run build

running example The transpiled code will be available in the build folder.

Testing And Transpiling typescript to javascript

A jasmine testing suite can be used to validate the endpoint as well as the imageTransform functionality.

npm run test

running test and build example

Formatting

The code can be automatically formatted using prettier. The formatting options can be customised by editin the .prettierrcfile.

npm run prettier

Linting

The code can ba automatically linted using ESlint. Note that ESlint will also use prettier to test for incorrect formatting. Rules, plugins and extensions for ESlint can be modified through the .eslintrc file.

npm run lint

running example

Running the server

To execute the application use the following command in terminal:

npm run start

running example the app will then be available on port 3000 by default, but that can be changed by editing the port constant value in the app.ts file.


How to use

The API offers one endpoint to access and resize images available in the public/images folder.

The endpoint is api/images and requires three query params:

Query Param Value
filename the filename (without extension) of one of the images available in the folder
height it should be a positive integer
width it should be a positive integer

Note that a preview of all the available images and their filenames can be accessed using the main API endpoint. Assuming the app is running on port 3000 that would be:

http://localhost:3000/api running example An example of a correct endpoint call would be:

http://localhost:3000/api/images?filename=fjord&height=100&width=200 running example

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published