This GitHub repository serves as the foundation of the cloud computing microservice project. It includes the initial setup of the development environment, GitHub repositories, an API server using Node.js and Express, structured logging, HTTP testing tools, npm scripts, and VSCode debugging configurations. The front end for this project can be found at here.
- Prerequisites/Dependencies
- Installation
- Development Tools
- Server Setup
- Testing
- Continuous Delivery
- Additional Information
- Acknowledgments
Notice, this was made using Windows 11 and PowerShell, code snippets might be different on Linux/Mac.
Before you begin, ensure you have the following installed:
-
Clone this repository to your local machine:
git clone https://github.com/benakram4/fragments.git cd fragments
-
Initialize the project and install dependencies:
npm init -y npm install
To lint your code and ensure code quality, run:
npm run lintPrettier is used for code formatting. It's automatically applied when you save files in VSCode.
We use Pino for structured logging. Logging configuration can be found in the src/logger.js file.
To start the server in production mode, use:
npm startThe server will run at http://localhost:8080.
To run the server in development mode with automatic code reloading (using Nodemon), use:
npm run devTo run the server in debug mode with the ability to attach a debugger, use:
npm run debugFor detailed instructions on how to use the VSCode debugger, including setting breakpoints, and inspecting variables, see:
- https://code.visualstudio.com/docs/editor/debugging
- https://code.visualstudio.com/docs/nodejs/nodejs-debugging
To run unit tests, use:
npm run test:unitTo run integration tests, use:
npm run test:integrationThis project uses a Continuous Delivery (CD) workflow to deploy updates.
The project uses Docker for containerization. The Dockerfile is linted using Hadolint, and images are built and pushed to Docker Hub.
The project is integrated with AWS for deploying Docker images to Amazon Elastic Container Service (ECS). AWS credentials are configured using GitHub secrets.
The .github/workflows/cd.yml file defines the CD workflow which triggers on pushing a new tag or commits to the main branch. The workflow includes steps to:
- Check out the code
- Set up Docker Buildx
- Configure AWS credentials
- Build and push Docker images to Amazon ECR
- Update ECS task definitions and deploy the new image
I faced some issues with installing jq on Windows 11. The jq documentation provides two installation methods:
-
Using Winget
You can install jq using the Winget package manager with this command:
winget install jqlang.jq
-
Downloading the Executable
You can download the jq executable directly, but this method requires manual addition of jq's PATH to the Windows environment variables.