Skip to content

This Express-API provides endpoints to retrieve log files and read the last N lines of a log file using Node streaming or FileHandle API. It also includes utility functions for directory traversal and log file reading.

Notifications You must be signed in to change notification settings

Ezugworie08/oroge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Oroge

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.

Features

  • 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.

Table of Contents

Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • npm (v8 or higher)
  • Current OS user (running this API) has admin privileges && permissions to READ /var/log or C:\\logs otherwise the test data directory ./test/data will be used.

Installation

  1. Clone the repository:

    git clone https://github.com/Ezugworie08/oroge.git
    cd oroge
  2. Install the dependencies

    npm install

Running the API

To start the API server, run the following command

npm start

The API will be available at http://localhost:3000.

API Endpoints

  • GET /logFiles: Get a list of log files in the respective logs directory (/var/log for unix or C:\\logs for windows and ./test/data as 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]
  • GET /health: Get health statistics of API server.

Testing

The project includes tests for both the API and the utility functions.

To run the tests:

npm test

Contributing

Contributions are welcome! If you find a bug or want to add a new feature, please open an issue or submit a pull request.

License

This project is licensed under the MIT license

About

This Express-API provides endpoints to retrieve log files and read the last N lines of a log file using Node streaming or FileHandle API. It also includes utility functions for directory traversal and log file reading.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published