- January 9, 2021
- Comments Disabled
Project Reasoning
The reason behind this project was to build up my knowledge in two fundamental areas, using Node.js within a cloud environment and rebuilding my backend web development skills. I have worked as a front end web developer in a previous role and continue to develop websites as a freelancer. However, when it comes to working with backend elements, I often use existing plugins or existing open-source solutions.
Project Aim
This project aimed to create a web front-end with a contact page to allow users to send a message to an approved email. As with similar projects, my focus was to deploy the necessary infrastructure using the CLI. In addition to this, I also wanted to experiment with local deployment using Docker and npm.
The Architecture
Creating the Environment
hen the “sendEmail” action would run and send the user's message and details to the email verified in SES.
Back End
As with other cloud projects, I planned to utilise serverless frameworks and use IaC as the foundation for the project. I began by deploying a Node.js starter application which gave me the necessary structure to build out. I declared the infrastructure, access levels and functions that would be required using YAML. This included access to Amazon SES and the call to the createContact handler function.
Front End
For the front-end I used an existing template using next.js, which deployed into the same working directory. I was able to run the application locally using the development server which I could then use for testing. I added a fetch API which allows the front end to access the values passed from the form. For debugging purposes, I added a console log so I could see what was being given. This is triggered by an “onSubmit” method attached to the send button which in turn triggers the “SendMessage” async function. Initially, I was receiving errors as the backend handler script was missing headers, so these were added to the “handler.js” file.