https://github.com/a-samod/sri-lanka-railways-location-api
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.
https://github.com/a-samod/sri-lanka-railways-location-api
express gps-tracking location-data mongodb nodejs rest-api sri-lanka-railways transportation
Last synced: 8 months ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/a-samod/sri-lanka-railways-location-api
- Owner: A-Samod
- License: mit
- Created: 2024-08-26T08:00:35.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-31T15:35:12.000Z (about 1 year ago)
- Last Synced: 2024-12-27T05:25:24.872Z (10 months ago)
- Topics: express, gps-tracking, location-data, mongodb, nodejs, rest-api, sri-lanka-railways, transportation
- Language: JavaScript
- Homepage:
- Size: 36.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# 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:**
```bash
git clone https://github.com/your-username/sri-lanka-railways-location-api.git
```
```bash
cd sri-lanka-railways-location-api
```
2. **Install dependencies:**
```bash
npm install
```
4. **Set up environment variables:**
```bash
MONGO_URI=mongodb://localhost:27017/railways
```
```bash
PORT=5000
```
5. **Start the application:**
```bash
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.
## 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](https://github.com/A-Samod/sri-lanka-railways-location-api?tab=MIT-1-ov-file#readme) file for details.