Skip to content

A Node.js REST API for Sri Lanka Railways to manage and retrieve real-time GPS location data of trains, with a 90-day data retention policy and CRUD operations on train data.

License

Notifications You must be signed in to change notification settings

A-Samod/sri-lanka-railways-location-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sri Lanka Railways Location API

This Node.js application serves as a RESTful API for Sri Lanka Railways, handling the ingestion, storage, and retrieval of real-time GPS location data for trains. The API supports CRUD operations on train data and maintains a 90-day data retention policy, allowing clients to access both current and historical location information.

Features

  • Ingest and store real-time GPS location data for trains.
  • Retrieve current and historical location data.
  • Maintain a 90-day data retention policy with automatic cleanup.
  • Perform CRUD operations on train data with history logging.

Prerequisites

  • Node.js (v14 or higher)
  • MongoDB
  • npm (Node Package Manager)

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/sri-lanka-railways-location-api.git
    cd sri-lanka-railways-location-api
  2. Install dependencies:

    npm install
  3. Set up environment variables:

    MONGO_URI=mongodb://localhost:27017/railways
    PORT=5000
  4. Start the application:

    npm start

API Endpoints

  • POST /location: Ingest GPS location data for a train.

  • GET /location/:trainId: Retrieve the current location of a specific train.

  • GET /location/history/:trainId: Retrieve historical location data for a specific train.

  • GET /train-history: Retrieve CRUD operation history for trains.

  • GET /location-history: Retrieve creation history logs for locations.

    image

Data Retention and Cleanup

The application automatically deletes location data older than 90 days, managed by a cron job running daily at midnight.

License This project is licensed under the MIT License. See the LICENSE file for details.

About

A Node.js REST API for Sri Lanka Railways to manage and retrieve real-time GPS location data of trains, with a 90-day data retention policy and CRUD operations on train data.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published