Welcome to the Oroge! This repository contains an Express API built using Node.js. The API provides endpoints to retrieve log files and read the last N lines of a log file using Node streaming API. It also includes utility functions for directory traversal and log file reading.
- List log files in a directory.
- Read the last N lines of a specific log file.
- Utility functions for directory traversal and log file reading with back pressure handling.
- Error handling and graceful shutdown.
- TODO: Comprehensive logging using Winston.
- Node.js (v18 or higher)
- npm (v8 or higher)
- Current OS user (running this API) has admin privileges && permissions to READ
/var/logorC:\\logsotherwise the test data directory./test/datawill be used.
-
Clone the repository:
git clone https://github.com/Ezugworie08/oroge.git cd oroge -
Install the dependencies
npm install
To start the API server, run the following command
npm startThe API will be available at http://localhost:3000.
GET /logFiles: Get a list of log files in the respective logs directory (/var/logfor unix orC:\\logsfor windows and./test/dataas backup). This endpoint will return a list of objects containing relative paths to the log files and their corresponding URL encoded counterparts. PLEASE provide the URL encoded paths to the next API endpoint below.GET /logFile: Get the last N lines of a log file.- Query parameters:
filepath: The path to the log file (URL encoded).limit(optional): The number of lines to return. Defaults to ten (10).q(optional): Search query to filter lines. Defaults to an empty string. PLEASE DO NOT QUOTE YOUR SEARCH STRING[S]
- Query parameters:
GET /health: Get health statistics of API server.
The project includes tests for both the API and the utility functions.
To run the tests:
npm testContributions are welcome! If you find a bug or want to add a new feature, please open an issue or submit a pull request.
This project is licensed under the MIT license