A Node.js application for logging flight API data, built with Express, MongoDB, and Mongoose. The app provides endpoints to store and manage flight API logs with validation using Joi.
- Node.js (v16 or higher)
- MongoDB (running locally or accessible via a connection string)
- Docker and Docker Compose (if running with Docker)
- npm (Node Package Manager)
-
Clone the repository:
git clone https://github.com/rashid-mamun/St-logger cd flight-api-logger -
Install dependencies:
npm install
-
Create a
.envfile in the root directory and configure the required environment variables (see Environment Variables).
-
Ensure MongoDB is running locally or provide a valid MongoDB connection string in the
.envfile. -
Start the application:
npm start
For development with auto-restart:
npm run start-dev
-
The app will be available at
http://localhost:5000.
You can run the application using either a single Docker container or Docker Compose (recommended for running both the app and MongoDB together).
-
Build the Docker image:
docker build -t flight-api-logger . -
Run the container, ensuring MongoDB is accessible (e.g., running locally or in another container):
docker run -p 5000:5000 --env-file .env flight-api-logger
-
The app will be available at
http://localhost:5000.
-
Ensure Docker Compose is installed.
-
Start the app and MongoDB containers:
docker-compose up --build
-
The app will be available at
http://localhost:5000, and MongoDB will be accessible atlocalhost:27017(if needed). -
To stop the containers:
docker-compose down
To stop and remove volumes (clear MongoDB data):
docker-compose down -v
Create a .env file in the root directory with the following variables:
PORT=5000
MONGODB_URI=mongodb://localhost/fpa-logger
PORT: The port the application runs on (default: 5000).MONGODB_URI: The MongoDB connection string (used for local runs; overridden in Docker Compose).
- GET /: Displays a welcome message ("App Online, 2023!").
- POST /flight-api-logger: Logs flight API data. Requires a JSON body with fields like
providerandexpiry. - GET /api: Returns a success message for testing.
Example POST request to /flight-api-logger:
{
"provider": "SABRE",
"expiry": "TEMPORARY",
"searchId": "12345",
"message": "Sample log",
"executionTime": "100ms",
"request": "Sample request",
"response": "Sample response",
"type": "INFO"
}