Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// v1.0
// Robert Benjamin
// robertbenjamin
// A BitBar menubar app for seeing when the next bus arrives at my work.
// http://i.imgur.com/zjuQRQF.png
// node,superagent,momentjs
// https://github.com/robertbenjamin/bit-bus
const bitbar = require('bitbar');
const request = require('superagent');
const moment = require('moment');
const busAPIKey = require('./src/API_KEY.js') || 'TEST';
let busStop = 18620;
let busAPI = `http://api.pugetsound.onebusaway.org/api/where/arrivals-and-departures-for-stop/1_${busStop}.json?key=${busAPIKey}&minutesAfter=70`;
let menuColor = bitbar.darkMode ? 'white' : 'black';
let warningColor = '#ff4136';
request
.get(busAPI)
.end((err, res) => {
if (err || !res.ok) bitbar([{ text: ':bus: no internet :(', color: warningColor }]);
let response = JSON.parse(res.text);
let trips = response.data.entry.arrivalsAndDepartures;
if (trips.length === 0) {
bitbar([{ text: ':bus: no more trips', color: warningColor }]);
} else {
let myTrips = trips
.filter(trip => trip.routeShortName === '32')
.map(trip => {