Skip to content
This repository has been archived by the owner on Jul 27, 2021. It is now read-only.

Commit

Permalink
fix: avoid creating auth instances when not needed (#405)
Browse files Browse the repository at this point in the history
  • Loading branch information
moliva authored Aug 21, 2019
1 parent 585e48a commit f0b68fe
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions packages/shared/world/profiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Profile, AvatarAsset, Colored, DclAssetUrl, ProfileSpec, Avatar, Avatar
import { Color4 } from '../../decentraland-ecs/src/decentraland/math/Color4'
import { getServerConfigurations, PREVIEW } from '../../config/index'
import defaultLogger from '../logger'
import { Auth } from 'shared/auth'

export async function resolveProfile(uuid: string = ''): Promise<Profile> {
let response
Expand Down Expand Up @@ -145,24 +144,20 @@ async function mapSpecToAvatar(avatar: AvatarSpec): Promise<Avatar> {
}

export async function fetchProfile(uuid: string = '') {
const auth = new Auth()

const request = await auth.createRequest(`${getServerConfigurations().profile}/profile${uuid ? '/' + uuid : ''}`)
const request = `${getServerConfigurations().profile}/profile${uuid ? '/' + uuid : ''}`
const response = await fetch(request)

return response
}

export async function createProfile(avatar: AvatarSpec) {
const auth = new Auth()

const body = JSON.stringify(avatar)
const options = {
method: 'PUT',
body
}

const request = await auth.createRequest(`${getServerConfigurations().profile}/profile/avatar`, options)
const request = `${getServerConfigurations().profile}/profile/avatar`
const response = await fetch(request, options)

return response
Expand Down

0 comments on commit f0b68fe

Please sign in to comment.