Control guest token caching from constant

This commit is contained in:
dangered wolf 2022-08-18 11:46:42 -04:00
parent eea9b82622
commit 897ba47ca2
No known key found for this signature in database
GPG key ID: 41E4D37680ED8B58
2 changed files with 4 additions and 3 deletions

View file

@ -18,6 +18,7 @@ export const Constants = {
API_DOCS_URL: `https://github.com/dangeredwolf/FixTweet/wiki/API-Home`, API_DOCS_URL: `https://github.com/dangeredwolf/FixTweet/wiki/API-Home`,
TWITTER_ROOT: 'https://twitter.com', TWITTER_ROOT: 'https://twitter.com',
TWITTER_API_ROOT: 'https://api.twitter.com', TWITTER_API_ROOT: 'https://api.twitter.com',
GUEST_TOKEN_MAX_AGE: 300, /* 5 minutes */
/* We used to use Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA /* We used to use Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA
but accounts marked as 18+ wouldn't show up then */ but accounts marked as 18+ wouldn't show up then */
GUEST_BEARER_TOKEN: `Bearer AAAAAAAAAAAAAAAAAAAAAPYXBAAAAAAACLXUNDekMxqa8h%2F40K4moUkGsoc%3DTYfbDKbT3jJPCEVnMYqilB28NHfOPqkca3qaAxGfsyKCs0wRbw`, GUEST_BEARER_TOKEN: `Bearer AAAAAAAAAAAAAAAAAAAAAPYXBAAAAAAACLXUNDekMxqa8h%2F40K4moUkGsoc%3DTYfbDKbT3jJPCEVnMYqilB28NHfOPqkca3qaAxGfsyKCs0wRbw`,

View file

@ -19,7 +19,7 @@ export const fetchUsingGuest = async (
headers: tokenHeaders, headers: tokenHeaders,
cf: { cf: {
cacheEverything: true, cacheEverything: true,
cacheTtl: 300 cacheTtl: Constants.GUEST_TOKEN_MAX_AGE
}, },
body: '' body: ''
} }
@ -33,7 +33,7 @@ export const fetchUsingGuest = async (
method: 'GET', method: 'GET',
cf: { cf: {
cacheEverything: true, cacheEverything: true,
cacheTtl: 300 cacheTtl: Constants.GUEST_TOKEN_MAX_AGE
} }
} }
); );
@ -153,7 +153,7 @@ export const fetchUsingGuest = async (
const cachingResponse = new Response(await activate.clone().text(), { const cachingResponse = new Response(await activate.clone().text(), {
headers: { headers: {
...tokenHeaders, ...tokenHeaders,
'cache-control': 'max-age=300' 'cache-control': `max-age=${Constants.GUEST_TOKEN_MAX_AGE}`
} }
}); });
console.log('Caching guest token'); console.log('Caching guest token');