1.0.1 • Published 10 months ago

aura-uptime v1.0.1

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
10 months ago

Aura Uptime

Aura Uptime is a powerful Node.js module designed to monitor the uptime of websites with high efficiency. Leveraging HTTP/2 and request compression, this module ensures requests are sent faster, making it highly suitable for uptime monitoring tasks. With extensive customization options and a JSON database, Aura Uptime is a top choice for those needing quick, reliable, and scalable uptime monitoring.

Features

  • High-Speed Monitoring: Utilizes HTTP/2 with request compression to enhance request speed, allowing for multiple simultaneous requests.
  • Customizable Monitoring Settings: Configure timeout durations, request counts, success codes, and more to tailor the monitoring to your needs.
  • Multiple Subscriptions: Choose between different subscription levels (Basic, Premium, Ultimate) to control request frequency and concurrent request limits.
  • JSON Database: All project data is saved in a JSON file, providing easy access and modifications.
  • Concurrency Control: Supports making multiple requests at the same time, significantly boosting the monitoring speed.
  • Flexible Project Management: Easily add, edit, and remove projects with simple commands.
  • Manual Requests: Perform manual checks on specific URLs to verify their status on demand.
  • Proxy Support: We support HTTP, SOCKS4 and SOCKS5 proxies.

Installation

npm install aura-uptime

Usage

Here’s an example of how to use Aura Uptime in your Node.js application:

const { UptimeClient } = require('aura-uptime');

// Client configuration
const client = new UptimeClient({
    name: "Aura Uptime",
    timeoutTime: 10000,
    requestCountInSameTime: 5,
    successRequestCodes: [200],
    database: "uptime/database.json",
    maxProjects: 500,
    maxRequestsToSave: 5,
    debug: true,
    subscriptions: [
        {
            name: "Basic",
            uptimeTime: 30000, // 30 seconds
            requestCountInSameTime: 3, // Sending requests in same time
        },
        {
            name: "Premium",
            uptimeTime: 15000, // 15 seconds
            requestCountInSameTime: 10, // Sending requests in same time
        },
        {
            name: "Ultimate",
            uptimeTime: 5000, // 5 seconds
            requestCountInSameTime: 20, // Sending requests in same time
        }
    ],
    proxies: [
        'Enter HTTP, SOCKS4 or SOCKS5 proxy to here'
    ] // Not required
});

async function run() {
    await client.initialize();

    // Adding a project
    const addProjectResult = await client.addProject({
        user: "817239812378123",
        url: "https://google.com",
        subscription: "Ultimate"
    });
    console.log("Add project result:", addProjectResult);

    // Editing a project
    const editProjectResult = await client.editProject({
        user: "817239812378123",
        url: "https://google.com",
        edit: { subscription: "Premium" }
    });
    console.log("Edit project result:", editProjectResult);

    // Fetching project information
    const project = await client.getProject({
        user: "817239812378123",
        url: "https://google.com"
    });
    console.log("Project info:", project);

    // Fetching all projects for a user
    const userProjects = await client.getUser('817239812378123');
    console.log("User Projects:", userProjects);

    // Making a manual request
    const manuelRequestResult = await client.manuelRequest({
        urls: ["https://google.com"],
        method: "GET"
    });
    console.log("Manual request result:", manuelRequestResult);

    // Removing a project
    const removeProjectResult = await client.removeProject({
        user: "817239812378123",
        url: "https://google.com"
    });
    console.log("Remove project result:", removeProjectResult);

    // Editing client settings
    const editClientResult = await client.editClient({
        timeoutTime: 15000,
        maxProjects: 1000
    });
    console.log("Edit client result:", editClientResult);

    // Start monitoring
    client.startMonitoring();

    // Stop monitoring after a specific time
    setTimeout(() => {
        client.stopMonitoring();
        console.log("Monitoring stopped.");
    }, 30000); // Stops monitoring after 30 seconds
}

run().catch(console.error);

Configuration Options

  • timeoutTime: Sets the timeout for each request.
  • requestCountInSameTime: Specifies the number of requests that can be made at the same time.
  • successRequestCodes: List of HTTP status codes considered as successful requests.
  • database: Path to the JSON database file where project data is stored.
  • maxProjects: Limits the maximum number of projects that can be added.
  • maxRequestsToSave: Determines how many recent requests will be saved in the database.
  • debug: Logs messages to console.
  • proxies: Uses proxies for requests

Subscription Levels

  • Basic: 10-minute interval between checks with up to 3 simultaneous requests.
  • Premium: 15-second interval between checks with up to 10 simultaneous requests.
  • Ultimate: 5-second interval between checks with up to 20 simultaneous requests.

Database Structure

  • name: The name of the monitoring service (e.g., "Aura Uptime").
  • timeoutTime: Timeout setting for requests.
  • successRequestCodes: Accepted HTTP status codes.
  • database: Path to the JSON database file.
  • subscriptions: Details of subscription plans, including uptimeTime and requestCountInSameTime.
  • projects: List of monitored projects, each containing:
    • user: The user's ID.
    • online: Status of the project (true/false).
    • lastCheck: Timestamp of the last check.
    • url: The monitored URL.
    • subscription: The subscription level.
    • requests: History of requests with details like online status, HTTP code, request ID, speed, and timestamp.

License

Apache 2.0 License