Skip to content

Commit

Permalink
fix post player data
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathaniel Moschkin committed Dec 5, 2023
1 parent 3d817bb commit 3a04572
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions app/logic/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,31 +93,41 @@ export class ApiClass {

async postPlayerData(dbid: string, player_data: any, logData: LogData): Promise<ApiResult> {
Logger.info('Post player data', { dbid, logData });
let res: Profile | undefined = undefined;

try {
await uploadProfile(dbid, player_data, new Date());
res = await uploadProfile(dbid, player_data, new Date());

this._player_data[dbid] = new Date().toUTCString();
fs.writeFileSync(`${process.env.PROFILE_DATA_PATH}/${dbid}`, JSON.stringify(player_data));

} catch (err) {
if (typeof err === 'string') {
return {
Status: 500,
Body: err
Body: { error: err }
};
}
else if (err instanceof Error) {
return {
Status: 500,
Body: err.toString()
Body: {error: err.toString() }
};
}
}

this._player_data[dbid] = new Date().toUTCString();
fs.writeFileSync(`${process.env.PROFILE_DATA_PATH}/${dbid}`, JSON.stringify(player_data));

return {
Status: 200,
Body: 'OK'
};
if (res) {
return {
Status: 200,
Body: res
};
}
else {
return {
Status: 500,
Body: { 'error': 'Unknown error' }
};
}
}

async loadGauntletStatus(logData: LogData): Promise<ApiResult> {
Expand Down

0 comments on commit 3a04572

Please sign in to comment.