Skip to content

Commit

Permalink
Expose TOKEN_TTL as env variable (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brainicism authored Aug 31, 2024
1 parent 0f595e3 commit 11423ba
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server/src/session_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@ export class SessionManager {
async generatePoToken(
visitIdentifier: string,
): Promise<YoutubeSessionData> {
const TOKEN_TTL_HOURS = process.env.TOKEN_TTL
? parseInt(process.env.TOKEN_TTL)
: 6;

const sessionData = this.youtubeSessionData[visitIdentifier];
if (
sessionData &&
sessionData.generatedAt >
new Date(new Date().getTime() - 6 * 60 * 60 * 1000)
new Date(
new Date().getTime() - TOKEN_TTL_HOURS * 60 * 60 * 1000,
)
) {
console.info(
`POT for ${visitIdentifier} still fresh, returning cached token`,
Expand Down

0 comments on commit 11423ba

Please sign in to comment.