chore: clean up and bump node version

This commit is contained in:
Jef LeCompte
2021-01-17 13:44:05 -05:00
parent b2ebac36c0
commit dbde7814af
19 changed files with 38 additions and 40 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ import {config} from '../config';
import {join} from 'path';
import notifier from 'node-notifier';
const desktop = config.notifications.desktop;
const {desktop} = config.notifications;
export function sendDesktopNotification(link: Link, store: Store) {
if (desktop) {
+1 -2
View File
@@ -3,8 +3,7 @@ import Discord from 'discord.js';
import {config} from '../config';
import {logger} from '../logger';
const discord = config.notifications.discord;
const {notifyGroup, webhooks, notifyGroupSeries} = discord;
const {notifyGroup, webhooks, notifyGroupSeries} = config.notifications.discord;
function getIdAndToken(webhook: string) {
const match = /.*\/webhooks\/(\d+)\/(.+)/.exec(webhook);
+1 -1
View File
@@ -4,7 +4,7 @@ import Mail from 'nodemailer/lib/mailer';
import {config} from '../config';
import nodemailer from 'nodemailer';
const email = config.notifications.email;
const {email} = config.notifications;
const transportOptions: any = {};
+1 -1
View File
@@ -3,7 +3,7 @@ import MqttClient, {IClientOptions, IClientPublishOptions} from 'mqtt';
import {Print, logger} from '../logger';
import {config} from '../config';
const mqtt = config.notifications.mqtt;
const {mqtt} = config.notifications;
let client: MqttClient.Client;
if (mqtt.broker) {
+16 -15
View File
@@ -3,18 +3,19 @@ import {config} from '../config';
import {v3 as hueAPI} from 'node-hue-api';
import {logger} from '../logger';
const hue = config.notifications.philips_hue;
const apiKey = hue.apiKey;
const bridgeIp = hue.bridgeIp;
const lightIds = hue.lightIds;
const lightColor = hue.lightColor;
const lightPattern = hue.lightPattern;
const LightState = hueAPI.lightStates.LightState;
const clientId = hue.clientId;
const clientSecret = hue.clientSecret;
const accessToken = hue.accessToken;
const refreshToken = hue.refreshToken;
const remoteApiUsername = hue.remoteApiUsername;
const {LightState} = hueAPI.lightStates;
const {
apiKey,
bridgeIp,
lightIds,
lightColor,
lightPattern,
clientId,
clientSecret,
accessToken,
refreshToken,
remoteApiUsername
} = config.notifications.philips_hue;
// Default Light State
const lightState = new LightState()
@@ -81,7 +82,7 @@ const adjustLightsWithAPI = (hueBridge: Api) => {
export function adjustPhilipsHueLights() {
// Check if the required variables have been set
if (hue.apiKey && hue.bridgeIp) {
if (apiKey && bridgeIp) {
logger.info('↗ adjusting Philips Hue lights over LAN');
(async () => {
logger.debug(
@@ -100,7 +101,7 @@ export function adjustPhilipsHueLights() {
}
);
})();
} else if (hue.apiKey && hue.clientId && hue.clientSecret) {
} else if (apiKey && clientId && clientSecret) {
logger.info('↗ adjusting Philips Hue lights over cloud');
(async () => {
logger.debug(
@@ -110,7 +111,7 @@ export function adjustPhilipsHueLights() {
clientId,
clientSecret
);
if (hue.accessToken && hue.refreshToken) {
if (accessToken && refreshToken) {
remoteBootstrap
.connectWithTokens(
accessToken,
+1 -1
View File
@@ -3,7 +3,7 @@ import {Print, logger} from '../logger';
import PushBullet from '@jef/pushbullet';
import {config} from '../config';
const pushbullet = config.notifications.pushbullet;
const {pushbullet} = config.notifications;
export function sendPushbulletNotification(link: Link, store: Store) {
if (pushbullet) {
+1 -1
View File
@@ -3,7 +3,7 @@ import {Print, logger} from '../logger';
import Push, {PushoverMessage} from 'pushover-notifications';
import {config} from '../config';
const pushover = config.notifications.pushover;
const {pushover} = config.notifications;
export function sendPushoverNotification(link: Link, store: Store) {
if (pushover.token && pushover.username) {
+3 -5
View File
@@ -3,13 +3,11 @@ import {Print, logger} from '../logger';
import {WebClient} from '@slack/web-api';
import {config} from '../config';
const slack = config.notifications.slack;
const channel = slack.channel.replace('#', '');
const token = slack.token;
const {channel, token} = config.notifications.slack;
const web = new WebClient(token);
export function sendSlackMessage(link: Link, store: Store) {
if (slack.channel && slack.token) {
if (channel && token) {
logger.debug('↗ sending slack message');
(async () => {
@@ -17,7 +15,7 @@ export function sendSlackMessage(link: Link, store: Store) {
try {
const result = await web.chat.postMessage({
channel,
channel: channel.replace('#', ''),
text: `${Print.inStock(link, store)}\n${givenUrl}`
});
+1 -1
View File
@@ -4,7 +4,7 @@ import Mail from 'nodemailer/lib/mailer';
import {config} from '../config';
import {transporter} from './email';
const [email, phone] = [config.notifications.email, config.notifications.phone];
const {email, phone} = config.notifications;
if (phone.number.length > 0 && (!email.username || !email.password)) {
logger.warn(
+1 -1
View File
@@ -3,7 +3,7 @@ import {Print, logger} from '../logger';
import {TelegramClient} from 'messaging-api-telegram';
import {config} from '../config';
const telegram = config.notifications.telegram;
const {telegram} = config.notifications;
const client = new TelegramClient({
accessToken: telegram.accessToken
+1 -1
View File
@@ -3,7 +3,7 @@ import {Print, logger} from '../logger';
import {Twilio} from 'twilio';
import {config} from '../config';
const twilio = config.notifications.twilio;
const {twilio} = config.notifications;
let client: Twilio;
if (twilio.accountSid && twilio.authToken) {
+1 -1
View File
@@ -5,7 +5,7 @@ import {existsSync, promises, readFileSync} from 'fs';
import {ChatClient} from 'twitch-chat-client';
import {config} from '../config';
const twitch = config.notifications.twitch;
const {twitch} = config.notifications;
const messages: string[] = [];
let alreadySaying = false;
+1 -1
View File
@@ -3,7 +3,7 @@ import {Print, logger} from '../logger';
import Twitter from 'twitter';
import {config} from '../config';
const twitter = config.notifications.twitter;
const {twitter} = config.notifications;
const client = new Twitter({
access_token_key: twitter.accessTokenKey,
+1 -1
View File
@@ -21,7 +21,7 @@ export async function processBackoffDelay(
* the page renders fine and its content is accessible.
*/
let backoffStatusCodes = store.backoffStatusCodes;
let {backoffStatusCodes} = store;
if (!backoffStatusCodes) {
backoffStatusCodes = [403];
+3 -3
View File
@@ -366,15 +366,15 @@ export function updateStores() {
updateStores();
export function getAllBrands() {
return Array.from(brands);
return [...brands];
}
export function getAllSeries() {
return Array.from(series);
return [...series];
}
export function getAllModels() {
return Array.from(models);
return [...models];
}
export function getStores() {
+1 -1
View File
@@ -120,7 +120,7 @@ function handleAPI(
sendConfig(response);
return;
case 'stores':
sendJSON(response, Array.from(storeList.keys()));
sendJSON(response, [...storeList.keys()]);
return;
case 'brands':
sendJSON(response, getAllBrands());