This project is a Subnet Calculator application that provides a REST API for calculating subnet details for IPv4 addresses. It includes a Node.js backend, an Nginx reverse proxy, and deployment automation using Ansible.
- Calculate subnet details for IPv4 addresses.
- REST API built with Hono and Zod for schema validation.
- Reverse proxy setup using Nginx.
- Deployment automation with Ansible.
- Dockerized environment for easy deployment.
The Node.js backend provides a REST API for calculating subnet details for IPv4 addresses.
- Built with Hono for lightweight and fast API development.
- Schema validation using Zod.
- Comprehensive logging with Winston.
- API documentation using OpenAPI, implemented with the
@hono/zod-openapilibrary for schema definitions and@scalar/hono-api-referencefor serving the documentation.
- Install dependencies:
npm install
- Run the development server:
npm run dev
- Build the project:
npm run build
- Run tests:
npm test
POST /api/calculate: Calculate subnet details for a given IPv4 CIDR address.GET /docs: Access the API documentation.
The Nginx reverse proxy is used for load balancing and forwarding client information.
- Load balancing between multiple Node.js API instances.
- Proxy headers for forwarding client information.
- Build the Nginx Docker image:
docker build -t webserver . - Run the container:
docker run -p 80:80 webserver
nginx.conf: Main configuration file for the Nginx server.
Ansible playbooks and roles are used for deploying the Subnet Calculator application.
- Setup Docker and required dependencies on the target server.
- Deploy Node.js API and Nginx reverse proxy using Docker Compose.
- Install Ansible:
pip install ansible
- Run the setup playbook to configure the server:
ansible-playbook -i inventory.ini setup.yaml
- Deploy the application:
ansible-playbook -i inventory.ini deploy.yaml
- Alternatively, you can use the
main.yamlfile to both set up and deploy the application in a single step:ansible-playbook -i inventory.ini main.yaml
roles/setup: Configures the server with Docker and required users.roles/deploy: Deploys the application using Docker Compose.
The project is fully containerized using Docker. Use the compose.yaml file to set up and run the entire application stack with Docker Compose.