Skip to content

A simple and efficient RESTful API for managing travel destinations, with image uploads and visit tracking.

Notifications You must be signed in to change notification settings

anuskagithub/TravelDestinationLog

Repository files navigation

🌍 Travel Destination Log

A full-stack Travel Destination Log Application built from scratch. This app includes a custom RESTful API server using Node.js and Express, connected to a MySQL database with image upload support, and a user-friendly frontend interface.

🧩 What I Built

  • βœ… A Node.js & Express powered REST API with full CRUD operations
  • βœ… Image upload support (multiple images per destination)
  • βœ… Endpoints to create, read, update, and delete travel logs
  • βœ… A professional frontend UI that:
    • Displays all destinations with travel date
    • Shows photos with left-right preview navigation
  • βœ… Tested API endpoints manually using cURL for robust validation

🌐 Tech Stack

  • Backend: Node.js, Express, MySQL (mysql2/promise)
  • Frontend: HTML, CSS, JavaScript
  • Image Handling: Multer
  • Testing: Jest, Supertest, Keploy
  • CI/CD: GitHub Actions
  • Docs: Swagger UI

πŸ“¦ Setup Instructions

🧰 Requirements

  • Node.js (v16+)
  • MySQL server
  • Docker (optional)

πŸ”§ Installation

git clone https://github.com/anuskagithub/TravelDestinationLog.git
cd TravelDestinationLog
npm install

πŸ› οΈ Database Setup

sql
CREATE DATABASE travel_db;

USE travel_db;

CREATE TABLE destinations (
  id INT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(255),
  location VARCHAR(255),
  description TEXT,
  date DATE,
  images TEXT
);

πŸš€ Application Running

πŸ”Œ Backend API Server

  • The Express server runs on:
    http://localhost:3000 image

  • Swagger API Docs:
    http://localhost:3000/api-docs image

🧾 API Endpoints

Method Endpoint Description
GET /destinations List all destinations
GET /destinations/:id Get a single destination by ID
POST /destinations Add a new destination (with images)
PUT /destinations/:id Update a destination
DELETE /destinations/:id Delete destination by ID
DELETE /destinations Delete all destinations

πŸ”„ CRUD API Operations

πŸ“₯ Create a Destination

bash
curl -X POST http://localhost:8080/api/destinations \
  -F "name=Paris" \
  -F "location=France" \
  -F "description=City of Light" \
  -F "date=2025-07-01" \
  -F "images=@/path/to/photo1.jpg" \
  -F "images=@/path/to/photo2.jpg"

πŸ“€ Read Destinations

bash
# Get all
curl http://localhost:8080/api/destinations

# Get by ID
curl http://localhost:8080/api/destinations/43

✏️ Update Destination

bash
curl -X PUT http://localhost:8080/api/destinations/3 \
  -H "Content-Type: application/json" \
  -d '{
        "name": "London",
        "location": "UK",
        "description": "City of History",
        "date": "2025-08-15"
      }'

❌ Delete Destination(s)

bash
# Delete by ID
curl -X DELETE http://localhost:8080/api/destinations/42

# Delete all
curl -X DELETE http://localhost:8080/api/destinations

βœ… Manual Testing Snapshots with cURL

πŸ”Ή Create Destination

Create Destination

πŸ”Ή Get All Destinations

Get All Destinations

πŸ”Ή Get Destination by ID

Get Destination by ID

πŸ”Ή Update Destination by ID

Update Destination by ID

πŸ”Ή Delete Destination by ID

Delete Destination by ID

πŸ“Š Test Coverage

  • βœ… Unit tests for service logic (mocked DB)
  • βœ… Integration tests for controller + DB + routes
  • βœ… API endpoint tests using Supertest
  • βœ… Edge case validation (missing fields, invalid IDs)
  • βœ… File upload & cleanup tests for images

πŸ§ͺ Coverage Metrics (via Jest)

Metric Percentage
Statements 85.85%
Branches 86.11%
Functions 92.85%
Lines 86.45%

πŸ“Œ Coverage is measured using jest --coverage

πŸ“Έ Coverage Report Screenshot

image

πŸ§ͺ API Testing using Keploy AI

βœ… 1. Record API Test Cases

bash
keploy record \
  -c "docker run -p 3000:3000 -e PORT=3000 --name travel-api-container --network keploy-network travel-api" \
  --container-name "travel-api-container" \
  --path ./keploy-test-data \
  --record-timer 1m \
  --build-delay 30

Make API requests (via Postman, browser, curl) during the record time.

πŸ” 2. Replay & Validate Tests

bash
keploy test \
  --path ./keploy-test-data \
  --container-name travel-api-container

βš™οΈ CI/CD Integration with GitHub Actions

πŸ“ .github/workflows/keploy-test.yml


yaml
name: Keploy API Testing

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  keploy-test:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Set up Docker
        uses: docker/setup-buildx-action@v3

      - name: Set up Keploy CLI
        run: |
          curl -sL https://dl.keploy.io/install.sh | bash
          echo "$HOME/.keploy/bin" >> $GITHUB_PATH

      - name: Build Docker image
        run: docker build -t travel-api .

      - name: Create Docker network
        run: docker network create keploy-network

      - name: Run container
        run: |
          docker run -d -p 3000:3000 --name travel-api-container \
            --network keploy-network -e PORT=3000 travel-api
          sleep 10

      - name: Run Keploy Tests
        run: |
          keploy test --path ./keploy-test-data --container-name travel-api-container

🐳 Docker Usage

πŸ“¦ Build and Run

bash
docker build -t travel-api .
docker run -p 3000:3000 --name travel-api-container --network keploy-network travel-api

πŸ™ With Docker Compose

bash
docker-compose up

Keploy API Testing

image

Test Report Summary


About

A simple and efficient RESTful API for managing travel destinations, with image uploads and visit tracking.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published