This is a Node.js-based image processing API that provides functionality for resizing images and logging HTTP requests and responses. It is a simple Image Processing API built with Node.js, Express, and the Sharp image processing library. It provides endpoints to resize images and log HTTP requests and responses. It is the first project for Udacity's Full Stack JavaScript Developer Nanodegree.
- Resize images to specified dimensions using the Sharp library.
- Log incoming HTTP requests and responses with timestamps.
- Node.js (v12 or higher)
- npm package manager
- Git (for cloning the repository)
- Clone the repository:
git clone https://github.com/kevinptx/udacity-image-processing-api cd image-processing-api npm install
- Install the required Node.js packages using npm:
npm install
- Build the TypeScript files:
npm run build
- Run the tests to ensure everything is set up correctly:
npm test
- Start the server:
npm start
- Open your web browser and navigate to http://localhost:3000 to access the Image Processing API.
To resize an image, send a GET request to /resize with the following query parameters:
- filename: The name of the image file you want to resize (including the file extension).
- width: The desired width of the resized image.
- height: The desired height of the resized image.
The Image Processing API allows you to resize images by sending a GET request to the following endpoint:
http://localhost:3000/resize?filename=<image-filename>&width=<desired-width>&height=<desired-height>
Example: http://localhost:3000/resize?filename=fjord.jpg&width=200&height=200
The resized image will be saved to disk on first access and then pulled from disk on subsequent access attempts. If the image processing fails or the image does not exist, an appropriate error message will be returned.
To view the logs of HTTP requests and responses, check the terminal where the server is running.
Query Parameters:
- filename (string, required): The name of the image file you want to resize (including the file extension).
- width (number, required): The desired width of the resized image.
- height (number, required): The desired height of the resized image.
Example: /resize?filename=fjord.jpg&width=200&height=200
Run the tests using the following command:
npm test
This project is licensed under the MIT License