1.0.0 • Published 5 years ago

statuspage.io-listener v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

statuspage.io-listener

Discord David NPM version NPM downloads GitHub Issues GitHub Last Commit License

Installation

$ npm i --save statuspage.io-listener
const StatusPage = require("statuspage.io-listener")

// url, readFunction, writeFunction, { interval: 10000 }
// functions can also have async if wanted
let listener = new StatusPage.Listener("https://metastatuspage.com/history.rss", readFunction, writeFunction)

listener.on('ready', () => { console.log("Ready!") })
listener.on('error', error => { console.error(error) })
listener.on('newItem', item => { console.log(item) })

// Example Read & Write Functions
const fs = require("fs")

function readFunction() {
    return fs.readFileSync("./pubDate.txt", "utf8")
}

function writeFunction(pubDate) {
    fs.writeFileSync("./pubDate.txt", pubDate, "utf8")
}

Item Example

{ title: 'Postmortem editing unavailable for some customers',
  description: 'On further investigation this issue turned out to be isolated to embedding images in postmortems. We’re closing this incident and will instead be sending this through our usual lower priority bug flow. Please reach out to support if you run into any issues.',
  pubDate: 'Fri, 14 Dec 2018 12:43:46 -0800',
  link: 'https://metastatuspage.com/incidents/mybtvbp3fjby',
  guid: 'https://metastatuspage.com/incidents/mybtvbp3fjby',
  type: 'Resolved' }