This project aims to give you a real-world scenario in which you would read and write to your disk via a Node.js express server rather than a database. The project you create serves two purposes: to prepare you for setting up scalable code and architecture for real-world projects and tie together some of the most popular middleware and utilities found in Node.js projects. This project barely touches the surface of what is possible but will prove your ability to use what you’ve learned in real-world scenarios.
The project can be built and run in the following ways
yarn
yarn build
This command will build the typeScript code into JavaScript and save them in the ./build
folder.
yarn start
This command will start the server running on port 3000
.
Here, I will show you how to run the test and also how to check that our code respects all the eslint rules.
yarn lint
yarn test
Method: get
URL Params: height
and width
- the height or width of the image in pixels
Query Param: filename
- the specific image you are requesting.
For example: `localhost:3000/api/images/preview/?filename=fjord`
Method: get
URL Params: height
and width
- the height or width of the image in pixels
Query Param: filename
- the specific image you are requesting.
For example: `localhost:3000/api/images/resize/?width=300&height=300&filename=fjord`
encenadaport
fjord
icelandwaterfall
palmtunnel
santamonica
- User can query endpoint using various params and queries to retrieve an image with a specified height and width.
- The default height and width is set to 200px.
- All images requested will be saved to disk.
- There is a cache layer. If a user requests an image size that has already been requested, there is no need for resizing and the previously resized image will be returned.
The project uses husky
for git
hooks. There are pre-commit hooks to run eslint
and prettier
on staged files. There is a pre-push hook that runs the unit tests. The configuration for this is present inside the package.json
file.
- NodeJS - The JavaScript runtime.
- Express - The web framework.
- TypeScript - The language used.
- Sharp - NodeJS image processor.