Skip to content

Commit

Permalink
Add endpoint for forced cache invalidation (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brainicism authored Aug 31, 2024
1 parent 11423ba commit 3b636f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,8 @@ httpServer.post("/get_pot", async (request, response) => {
const sessionData = await sessionManager.generatePoToken(visitorIdentifier);
response.send({ po_token: sessionData.poToken });
});

httpServer.post("/invalidate_caches", async (request, response) => {
sessionManager.invalidateCaches();
response.send();
});
4 changes: 4 additions & 0 deletions server/src/session_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export class SessionManager {
[visitIdentifier: string]: YoutubeSessionData;
} = {};

invalidateCaches() {
this.youtubeSessionData = {};
}

// mostly copied from https://github.com/LuanRT/BgUtils/tree/main/examples/node
async generatePoToken(
visitIdentifier: string,
Expand Down

0 comments on commit 3b636f2

Please sign in to comment.