diff options
author | mat <27899617+mat-1@users.noreply.github.com> | 2021-02-20 22:51:15 -0600 |
---|---|---|
committer | mat <27899617+mat-1@users.noreply.github.com> | 2021-02-20 22:51:15 -0600 |
commit | d4b71f8dab86e95cd50f808fdbd2155f73e84469 (patch) | |
tree | b4ea8ef8feb7d41cbd36f2aee69116911a684ecf | |
parent | 31b2ae8af35378969497532b9cdb75f40472c316 (diff) | |
download | skyblock-api-d4b71f8dab86e95cd50f808fdbd2155f73e84469.tar.gz skyblock-api-d4b71f8dab86e95cd50f808fdbd2155f73e84469.tar.bz2 skyblock-api-d4b71f8dab86e95cd50f808fdbd2155f73e84469.zip |
add debug stuff
-rw-r--r-- | src/hypixel.ts | 2 | ||||
-rw-r--r-- | src/hypixelCached.ts | 9 | ||||
-rw-r--r-- | 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<CleanBasicProfile[]> { */ 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 |