From d4b71f8dab86e95cd50f808fdbd2155f73e84469 Mon Sep 17 00:00:00 2001 From: mat <27899617+mat-1@users.noreply.github.com> Date: Sat, 20 Feb 2021 22:51:15 -0600 Subject: add debug stuff --- src/hypixel.ts | 2 ++ src/hypixelCached.ts | 9 +++++---- src/index.ts | 3 +++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/hypixel.ts b/src/hypixel.ts index 6c19a69..83ad419 100644 --- a/src/hypixel.ts +++ b/src/hypixel.ts @@ -8,6 +8,7 @@ import * as cached from './hypixelCached' import { CleanBasicMember, CleanMemberProfile } from './cleaners/skyblock/member' import { cleanSkyblockProfileResponse, CleanProfile, CleanBasicProfile } from './cleaners/skyblock/profile' import { cleanSkyblockProfilesResponse } from './cleaners/skyblock/profiles' +import { debug } from '.' export type Included = 'profiles' | 'player' | 'stats' | 'inventories' @@ -78,6 +79,7 @@ export async function fetchUser({ user, uuid, username }: UserAny, included: Inc } if (!uuid) { // the user doesn't exist. + if (debug) console.log('error:', user, 'doesnt exist') return null } diff --git a/src/hypixelCached.ts b/src/hypixelCached.ts index e311fe6..1b8b617 100644 --- a/src/hypixelCached.ts +++ b/src/hypixelCached.ts @@ -8,11 +8,9 @@ import * as hypixel from './hypixel' import { CleanPlayer } from './cleaners/player' import { undashUuid } from './util' import { CleanProfile, CleanFullProfile, CleanBasicProfile } from './cleaners/skyblock/profile' +import { debug } from '.' -// TODO: put this somewhere else -const debug = false - // cache usernames for 4 hours const usernameCache = new NodeCache({ @@ -185,7 +183,10 @@ async function fetchBasicProfiles(user: string): Promise { */ export async function fetchProfileUuid(user: string, profile: string) { // if a profile wasn't provided, return - if (!profile) return null + if (!profile) { + if (debug) console.log('no profile provided?', user, profile) + return null + } const profiles = await fetchBasicProfiles(user) diff --git a/src/index.ts b/src/index.ts index c0047ad..adeab57 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,6 +3,9 @@ import express from 'express' const app = express() +export const debug = false + + app.use((req, res, next) => { if (process.env.key && req.headers.key !== process.env.key) // if a key is set in process.env and the header doesn't match return an error -- cgit