New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rutilus-apiheartbeat-node

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rutilus-apiheartbeat-node - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

LICENSE

7

heartbeat.js
/**
* Rutilus
*
* @website https://gmrutilus.github.io
* @license Apache-2.0
*/
/**
* Module for heartbeat

@@ -3,0 +10,0 @@ */

@@ -0,1 +1,8 @@

/**
* Rutilus
*
* @website https://gmrutilus.github.io
* @license Apache-2.0
*/
const Heartbeat = require('./heartbeat');

@@ -2,0 +9,0 @@

4

package.json
{
"name": "rutilus-apiheartbeat-node",
"version": "0.0.7",
"version": "0.0.8",
"description": "Makes constant requests to urls and logs whether the response was successful and the response time. Can be configured to throw errors if the response fails in order to crash containers.",

@@ -36,3 +36,3 @@ "main": "index.js",

],
"license": "UNLICENSED"
"license": "Apache-2.0"
}

@@ -1,79 +0,8 @@

# Rutilus - API Heartbeat - Node
# rutilus-apiheartbeat-node
An optional module that makes requests to log whether the requests were successful and the response time.
This module makes constant requests to urls and logs whether the response was successful and the response time.
# Documentation
See [the official documentation website](https://gmrutilus.github.io/#/docs/apiheartbeat/node).
The module can be set to throw errors if the URL does not respond in order to crash containers.
Example: if we are deploying a cluster of containers with several APIs and want to make sure all the APIs are responding properly, we can set up this module to watch all the APIs and throw an error to crash the container (which will be restarted) in case one of them stops responding.
A request will be considered unsuccessful if the application does not receive a response before the next request. For example: if we set the API Heartbeat to make one request every 10 seconds, a response that takes more than 10 secons to be received will be considered unsuccessful.
This module constantly monitors the size of the log files, and a maximum size can be set. When the maximum size of the file is reached, the file is archived (receiving a "ARCHIVED_" suffix) and blank, new file is created. If there already is an archived log file, it will be replaced.
This module does not have dependencies.
## Installing
```
npm install rutilus-apiheartbeat-node --save
```
## Using
Require the module in the project and call it by passing 2 parameters, the last one being optional:
### First parameter
An array of objects that describe the APIs to be monitored:
```
[
{
title: String (optional, defaults to "Untitled")
address: String
useHttps: Boolean (optional, defaults to "false")
logDirectory: String (optional, defaults to "")
logFile: String,
timeSpan: Number (optional, defaults to "10000")
maxFileSizeBytes: Number (optional, defaults to "10000000")
crashWhenFail: Boolean (optional, defaults to "false")
}
]
```
- **title**: A meaningful title for the API
- **address**: The URL of the api
- **useHttps**: Use HTTP or HTTPS for making the request?
- **logDirectory**: Directory where the logs must be saved
- **logFile**: Name of the file for the logs
- **timeSpan**: Time span (ms) for every heartbeat. Minimum: 10 seconds.
- **maxFileSizeBytes**: Maximum size for the log file - when the size exceeds the one specified, the old logs get archived ("ARCHIVE_" + log file name). If there already is an archived version, it gets overwritten.
- **crashWhenFail**: If set to true, when an API fails, this module will throw an error. Useful for crashing containers and making them restart.
### Second parameter (optional, defaults to 0)
A number that delays the start of the heartbeat.
Example: 10000 (for 10 seconds)
### Example
```
const APIHeartbeat = require('rutilus-apiheartbeat-node');
APIHeartbeat([{
title: 'My API 1',
address: 'https://www.api1.com/',
useHttps: true,
logDirectory: '/logs',
logFile: 'api1.log',
timeSpan: 10000,
maxFileSizeBytes: 1000000,
crashWhenFail: true,
}, {
title: 'My API 2',
address: 'http://www.api2.com:3000/',
useHttps: false,
logDirectory: '/logs/api2',
logFile: 'api2.log',
timeSpan: 60000,
}], 5000);
```
# License
Apache 2.0
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc