Skip to content

Commit

Permalink
💡 cache bust on group search forward
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaTheMiller committed Jun 6, 2023
1 parent 6ef6b9b commit 51e02c5
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions src/services/ldapClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,30 +107,12 @@ async function SearchAllAsyncNoExceptionHandling(groupName: string): SearchAllRe
// }
// })
});
}

async function SearchAllAsyncInternal(groupName: string): SearchAllResponse {
try {
return await SearchAllAsyncNoExceptionHandling(groupName);
}
catch {
return {
entries: [] as Entry[],
referrals: []
}
}
}
}

export async function SearchAllAsync(groupName: string): SearchAllResponse {
try {
if(process.env.SOURCE_PROXY) {
console.log(`Forwarding request to '${process.env.SOURCE_PROXY}'`);

const requestUrl = `${process.env.SOURCE_PROXY}/api/get-source-team?teamName=${groupName}`

const result = await axios.get(requestUrl);

return result.data;
return await ForwardSearch(groupName);
}

return await SearchAllAsyncNoExceptionHandling(groupName);
Expand All @@ -141,4 +123,15 @@ export async function SearchAllAsync(groupName: string): SearchAllResponse {
referrals: []
}
}
}
}

async function ForwardSearch(groupName: string) {
console.log(`Forwarding request to '${process.env.SOURCE_PROXY}'`);

// cb is for cache busting.
const requestUrl = `${process.env.SOURCE_PROXY}/api/get-source-team?teamName=${groupName}&cb=${Date.now()}`;

const result = await axios.get(requestUrl);

return result.data;
}

0 comments on commit 51e02c5

Please sign in to comment.