Skip to content

Commit

Permalink
chore: clean up and bump node version
Browse files Browse the repository at this point in the history
  • Loading branch information
jef committed Jan 17, 2021
1 parent b2ebac3 commit dbde781
Show file tree
Hide file tree
Showing 19 changed files with 38 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2.1.4
with:
node-version: 14.15.0
node-version: 14.15.4
- uses: actions/cache@v2
with:
path: ~/.npm
Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.15.0
14.15.4
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "streetmerchant",
"description": "🔮 For all your Nvidia needs",
"description": "The world's easiest, most powerful stock checker",
"main": "src/index.ts",
"scripts": {
"all": "npm run build && npm run lint",
Expand Down
2 changes: 1 addition & 1 deletion src/notification/desktop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions src/notification/discord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/notification/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};

Expand Down
2 changes: 1 addition & 1 deletion src/notification/mqtt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
31 changes: 16 additions & 15 deletions src/notification/philips-hue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -110,7 +111,7 @@ export function adjustPhilipsHueLights() {
clientId,
clientSecret
);
if (hue.accessToken && hue.refreshToken) {
if (accessToken && refreshToken) {
remoteBootstrap
.connectWithTokens(
accessToken,
Expand Down
2 changes: 1 addition & 1 deletion src/notification/pushbullet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/notification/pushover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 3 additions & 5 deletions src/notification/slack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@ 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 () => {
const givenUrl = link.cartUrl ? link.cartUrl : link.url;

try {
const result = await web.chat.postMessage({
channel,
channel: channel.replace('#', ''),
text: `${Print.inStock(link, store)}\n${givenUrl}`
});

Expand Down
2 changes: 1 addition & 1 deletion src/notification/sms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/notification/telegram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/notification/twilio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/notification/twitch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/notification/twitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/store/model/helpers/backoff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
6 changes: 3 additions & 3 deletions src/store/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/web/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit dbde781

Please sign in to comment.