Merge pull request #731 from TNG-dev/zkldi/issue-730

This commit is contained in:
Kiam
2022-06-21 22:29:40 +01:00
committed by GitHub
5 changed files with 15 additions and 7 deletions
+1
View File
@@ -45,6 +45,7 @@ not generally be shown to end users.
- [ENH] Server administrators can now revert other's imports.
- [ENH] You can now set Jubility targets.
- [ENH] Folder Showcase Stats are now removed from a player in the case of the folder being removed.
- [ENH] ARC SDVX Support has been bumped to EXCEED GEAR.
- [INTERNAL_ENH] Server version info is now read from package.json, removing redundancy.
- [INTERNAL_ENH] The commit the server is running under is now exposed publically in version info.
# 2.1.18
@@ -11,13 +11,13 @@ const logger = CreateLogCtx(__filename);
t.test("#ParseArcSDVX", (t) => {
t.beforeEach(ResetDBState);
const mockArcAPI = MockJSONFetch({
"https://arc.example.com/api/v1/sdvx/5/player_bests/?profile_id=profile": {
"https://arc.example.com/api/v1/sdvx/6/player_bests/?profile_id=profile": {
_links: {
_next: "https://arc.example.com/api/v1/sdvx/5/player_bests/?profile_id=profile&page=2",
_next: "https://arc.example.com/api/v1/sdvx/6/player_bests/?profile_id=profile&page=2",
},
_items: [1, 2, 3],
},
"https://arc.example.com/api/v1/sdvx/5/player_bests/?profile_id=profile&page=2": {
"https://arc.example.com/api/v1/sdvx/6/player_bests/?profile_id=profile&page=2": {
_links: {
_next: null,
},
@@ -24,9 +24,9 @@ export async function ParseArcSDVX(
iterable: TraverseKaiAPI(
ServerConfig.ARC_API_URL,
// VIVID WAVE.
// EXCEED GEAR.
// The trailing slash is critical! ARC only allows /? queries.
`/api/v1/sdvx/5/player_bests/?profile_id=${authDoc.accountID}`,
`/api/v1/sdvx/6/player_bests/?profile_id=${authDoc.accountID}`,
ServerConfig.ARC_AUTH_TOKEN,
logger,
null,
@@ -112,13 +112,19 @@ export async function* TraverseKaiAPI(
continue;
}
let text;
try {
// Split this into text -> JSON parse so we can read the text for better error messages
// in the case of disaster.
// eslint-disable-next-line no-await-in-loop
json = (await res.json()) as unknown;
text = await res.text();
json = JSON.parse(text) as unknown;
} catch (err) {
logger.error(
`Received invalid (non-json) response from ${url}. Status code was ${res.status}.`,
{ err }
{ err, text }
);
throw new ScoreImportFatalError(
500,
+1
View File
@@ -20,6 +20,7 @@ export function MockJSONFetch(urlDataMap: Record<string, unknown>) {
if (url in urlDataMap) {
const fakeResponse = {
status: 200,
text: () => Promise.resolve(JSON.stringify(urlDataMap[url])),
json: () => Promise.resolve(urlDataMap[url]),
} as unknown as Response;