aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2021-02-13 20:26:37 -0600
committermat <27899617+mat-1@users.noreply.github.com>2021-02-13 20:26:37 -0600
commitcf8b4923974e9f685209dc1218be20a06cc0f5c9 (patch)
tree8601d88ff265551fba9e2a05641981a505b9a281 /src
parentcd707234194b41df933a3a287b5fbec3657063d5 (diff)
downloadskyblock-api-cf8b4923974e9f685209dc1218be20a06cc0f5c9.tar.gz
skyblock-api-cf8b4923974e9f685209dc1218be20a06cc0f5c9.tar.bz2
skyblock-api-cf8b4923974e9f685209dc1218be20a06cc0f5c9.zip
fix caching issue
if you visited player/:user then player/:user/:profile it would error
Diffstat (limited to 'src')
-rw-r--r--src/cleaners/skyblock/member.ts21
-rw-r--r--src/cleaners/skyblock/profiles.ts1
-rw-r--r--src/hypixelCached.ts7
3 files changed, 20 insertions, 9 deletions
diff --git a/src/cleaners/skyblock/member.ts b/src/cleaners/skyblock/member.ts
index 04aa476..796d524 100644
--- a/src/cleaners/skyblock/member.ts
+++ b/src/cleaners/skyblock/member.ts
@@ -1,13 +1,14 @@
-import { Included } from '../../hypixel'
-import * as cached from '../../hypixelCached'
-import { CleanPlayer } from '../player'
-import { Bank } from './bank'
-import { cleanFairySouls, FairySouls } from './fairysouls'
+import { CleanProfileStats, cleanProfileStats } from './stats'
import { cleanInventories, INVENTORIES } from './inventory'
-import { CleanMinion, cleanMinions } from './minions'
+import { cleanFairySouls, FairySouls } from './fairysouls'
import { cleanObjectives, Objective } from './objectives'
+import { CleanMinion, cleanMinions } from './minions'
+import { cleanSkills, Skill } from './skills'
+import * as cached from '../../hypixelCached'
import { CleanFullProfile } from './profile'
-import { CleanProfileStats, cleanProfileStats } from './stats'
+import { Included } from '../../hypixel'
+import { CleanPlayer } from '../player'
+import { Bank } from './bank'
export interface CleanBasicMember {
uuid: string
@@ -17,11 +18,13 @@ export interface CleanBasicMember {
}
export interface CleanMember extends CleanBasicMember {
+ purse: number
stats: CleanProfileStats
minions: CleanMinion[]
fairy_souls: FairySouls
inventories: typeof INVENTORIES
objectives: Objective[]
+ skills: Skill[]
}
export async function cleanSkyBlockProfileMemberResponseBasic(member, included: Included[] = null): Promise<CleanBasicMember> {
@@ -43,12 +46,14 @@ export async function cleanSkyBlockProfileMemberResponse(member, included: Inclu
last_save: member.last_save,
first_join: member.first_join,
+ purse: member.coin_purse,
+
stats: cleanProfileStats(member),
minions: cleanMinions(member),
fairy_souls: cleanFairySouls(member),
inventories: inventoriesIncluded ? await cleanInventories(member) : undefined,
objectives: cleanObjectives(member),
- // skills: statsIncluded ?
+ skills: cleanSkills(member)
}
}
diff --git a/src/cleaners/skyblock/profiles.ts b/src/cleaners/skyblock/profiles.ts
index 5eea8fb..c942a14 100644
--- a/src/cleaners/skyblock/profiles.ts
+++ b/src/cleaners/skyblock/profiles.ts
@@ -9,6 +9,7 @@ export function cleanPlayerSkyblockProfiles(rawProfiles: HypixelPlayerStatsSkyBl
name: profile.cute_name
})
}
+ console.log('cleanPlayerSkyblockProfiles', profiles)
return profiles
}
diff --git a/src/hypixelCached.ts b/src/hypixelCached.ts
index bf3124a..f98f6d6 100644
--- a/src/hypixelCached.ts
+++ b/src/hypixelCached.ts
@@ -8,6 +8,7 @@ import * as hypixel from './hypixel'
import { CleanPlayer } from './cleaners/player'
import { undashUuid } from './util'
import { CleanProfile, CleanFullProfile, CleanBasicProfile } from './cleaners/skyblock/profile'
+import { cleanProfileStats } from './cleaners/skyblock/stats'
// cache usernames for 4 hours
@@ -100,7 +101,11 @@ export async function fetchPlayer(user: string): Promise<CleanPlayer> {
path: 'player',
args: { uuid: playerUuid }
})
- playerCache.set(playerUuid, cleanPlayer)
+
+ // clone in case it gets modified somehow later
+ const cleanPlayerClone = Object.assign({}, cleanPlayer)
+ playerCache.set(playerUuid, cleanPlayerClone)
+
return cleanPlayer
}