RESTful API developed in Node.js + TypeScript for integration with AviationStack and for querying flight and airline information.
Includes a complete environment with Docker Compose, automated tests, and fallback in case of external failures.
Build and test automation via GitHub Actions
- Node.js (Express, TypeScript)
- MySQL 8
- Redis
- phpMyAdmin
- Mailhog (email testing)
- Make sure you have Docker and Docker Compose installed.
- Copy the
.env.examplefile to.envand adjust variables if necessary. - To build the images and create the volumes, run
make init- To start all services use:
make start- To stop them use:
make stop-devYou can try the API deployed on Cloud Run here:
👉 https://aviation-integration-944235041157.us-central1.run.app/
- Healthcheck: /api/health
- Swagger UI: /docs
- Flights example: /api/v1/flights?dep_iata=GUA
- Airports example: /api/v1/airports?search=guatemala
- Airlines example: /api/v1/airlines?search=VX
make init # Initialize network, volumes, and services
make start # Start all development services
make stop-dev # Stop all development services
make node-shell # Enter Node.js terminal
make db-shell # Enter MySQL terminal
make redis-shell # Enter Redis terminal
make mailhog # Open Mailhog in the browser
make phpmyadmin # Open phpMyAdmin in the browser
make test # Run tests inside the Node.js containerSee .env.example for the necessary configuration.
Glossary:
| Variable | Description |
|---|---|
| NODE_ENV | Environment (development, production, etc) |
| PORT | API port (default: 8080) |
| AVIATIONSTACK_KEY | AviationStack API Key |
| AVIATIONSTACK_URL | AviationStack API URL |
| MYSQL_* | MySQL configuration |
| REDIS_* | Redis configuration |
| MAIL** / GMAIL** | SMTP/Mailhog/Gmail for testing |
- Swagger UI: https://aviation-integration-944235041157.us-central1.run.app/docs
- docs/API.md — English version with endpoints summary, parameters and examples
- Main endpoints:
| Method | Path | Description |
|---|---|---|
| GET | /api/v1/airlines | List of airlines with local search |
| GET | /api/v1/airports | List of airports with local search |
| GET | /api/v1/flights | Flight search with multiple filters |
| GET | /api/health | Check the status of all services |
All query parameters are validated with Joi, and validation errors return HTTP 422.
See src/utils/airportValidator.ts, src/utils/flightsValidator.ts y src/utils/airlineValidator.ts.
- If the external API fails, the system first checks Redis, then MySQL.
- All successful external responses are automatically persisted.
- A TTL is applied to Redis cache.
Full support for:
- ✔️ Unit tests for controllers, services, validators, and middleware
- ✔️ Integration tests for REST endpoints
- ✔️ Data mocking for
NODE_ENV=testto avoid real calls to AviationStack
To run:
make init
make test- Data flow diagram:
docs/data-flow.puml - Architecture diagram:
docs/architecture.puml
- MySQL won't start? Delete the Docker volume:
docker volume rm aviation_db_data
- API not responding on port? Check your
.envand exposed ports.
- Automatic deploy:
When mergingdevelop→master, it deploys to Cloud Run via GitHub Actions and theGCP_SA_KEYsecret. - Manual deploy:
If you need to deploy manually:
- Obtain a service account key in JSON format with
Cloud Run Admin,Storage Admin, andCloud Buildpermissions. - Authenticate with:
gcloud auth activate-service-account --key-file gcp-key.json
- Launch the deploy:
make deploy
- Obtain a service account key in JSON format with
- Run before every PR
npm run lint
npm run format- Audit dependencies regularly with
npm auditPlease review the CONTRIBUTING.md before submitting a pull request.
MIT
Author: @jdanielrodriguez