Skip to content

andranikarakelyan/api-heartbeat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API Heartbeat

A minimal Node.js application that repeatedly calls an API endpoint at configurable intervals.

Setup

  1. Install dependencies:

    npm install
  2. Create environment configuration:

    cp .env.example .env

    Then edit .env with your actual values.

Configuration

Configure the application using environment variables in the .env file:

  • API_URL (required): The full URL to call
  • API_HEADERS (optional): A JSON string representing HTTP headers
  • CALL_INTERVAL_MS (required): Interval between calls in milliseconds

Environment Variables

Variable Required Description Example
API_URL The full URL to call https://api.example.com/health
API_HEADERS HTTP headers as JSON string {"Authorization": "Bearer token123"}
CALL_INTERVAL_MS Interval between calls in milliseconds 5000 (5 seconds)

Example .env file

API_URL=https://api.example.com/health
API_HEADERS={"Authorization": "Bearer your-token-here", "Content-Type": "application/json"}
CALL_INTERVAL_MS=60000

Running

npm start

Example Output

Starting API heartbeat to https://api.example.com/health every 60000ms
[2025-08-25T10:30:00.000Z] Status: 200 OK
[2025-08-25T10:31:00.000Z] Status: 200 OK
[2025-08-25T10:32:00.000Z] Error: fetch failed

About

A tiny Node.js app that pings an API every minute to keep jobs running.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors