back-end development | JavaScript | Sharp npm module | Github | AWS Lambda
Link to GitHub repository: imageResizer
Built in Node.js; deployed on AWS Lambda via Amazon API Gateway
Test API here
While putting together my web development projects I kept running into issues regarding my images. Sometimes an image would be the incorrect dimensions, needs cropping, or could use rotation to fit better on page. This created a need for me to create an image resizer that would load images quickly exactly as I want them to look.
As I began the building process, I made this list of objectives to keep me on track:
Before any actual coding took place, I registered with AWS Lambda here! Once my registration was locked and loaded I created my AWS lambda zip with `sharp` and `request` npm packages. This link will help you in the steps in getting set up!
Writing the code:
Deploying to Lambda gateway:
Configuring API gateway
Challenges:
AWS Lambda doesn't have a good way for rapidly testing your code locally. It takes several minutes to rebuild, redeploy, and run tests that could all fail because of syntax error. The simplest way to test your code is by setting up a simple Express server is a quick way to debug logical coding. However, This doesn't emulate many of the API Gateway configurations though which can be quite confusing the first time you use them. There are some frameworks that are attempting to bridge the gap between local development and a full serverless deployment. I will be evaluating them for any furture serverless projects.
Now I have a fast-loading, effective image manipulator that resizes, blurs, rotates, and crops .png files. Try here to have a look yourself!