bitsler-status

node v8.11.2
version: 1.0.3
endpointsharetweet
const endpoint = require("@runkit/uniibu/json-api/releases/1.0.1"); const needle = require("needle") const services = ['BITSLER_WEBSITE','BITSLER_CHAT','BITSLER_API','BITSLER_FORUM'] const staturl = 'https://api.uptimerobot.com/v2/getMonitors' const req = async function(url,data){ const opts = { headers : {'cache-control':'no-cache'} } try{ const resp = await needle('post',url,data,opts) return resp.body }catch(e){ return false; } } const getStats = async function(){ const payload = {} for(const s of services){ console.log(s,process.env[s]) const data = { api_key: process.env[s] || '', format: 'json', custom_uptime_ratios: '1-7-30', response_times_average: 30, //response_times: 1 } let d = await req(staturl,data) console.log(d) d = d.monitors[0] payload[s] = { name: d.friendly_name, url: d.url, status: d.status === 2 ? 'Operational' : (d.status === 8 ? 'Degraded': 'Outage'), sincetime: d.create_datetime, uptime: d.custom_uptime_ratio.split('-'), // response_history: d.response_times, // response_avg: d.average_response_time } } return payload; } endpoint(module.exports, async function(request) { const payload = await getStats() return payload })
Loading…

no comments

    sign in to comment