You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should extract many other implicit constants ... to proper constant files
Do we want to just move the object to a constants file like this
// src/constants/r2Prefixes.tsexportfunctiongetUrlToBucketPathMap(url){return{dist: DIST_PATH_PREFIX+(url.pathname.substring('/dist'.length)||'/'),download:
DOWNLOAD_PATH_PREFIX+(url.pathname.substring('/download'.length)||'/'),docs: DOCS_PATH_PREFIX+(url.pathname.substring('/docs'.length)||'/'),api: API_PATH_PREFIX+(url.pathname.substring('/api'.length)||'/'),metrics: url.pathname.substring(1),// substring to cut off the /}}// src/util.tsconsturlToBucketPathMap=getUrlToBucketPathMap(url);// ...}elseif(basePathinurlToBucketPathMap){bucketPath=urlToBucketPathMap[basePath];}
or can we do something like this, where we only construct the url we need rather than all of them
I think it's important to mention that we have numerous constant files and it would make sense to have similar constants grouped together (ie. assume we have multiple constants for dist related things or download/ related things, it makes sense to have all these paths and logic to be close together
Is there a reason behind why dist: () => `${DIST_PATH_PREFIX}${url.pathname.substring('/dist'.length) || '/'}`, instead of dist: DIST_PATH_PREFIX + (url.pathname.substring('/dist'.length) || '/'),?
Do we want to tell clients to locally cache HEAD requests? It's what we're doing now, but given we don't cache them on the worker's end I wanted to double check
Activity
flakey5 commentedon Nov 15, 2023
Do we want to just move the object to a constants file like this
or can we do something like this, where we only construct the url we need rather than all of them
or was there something else you were thinking about?
fix: caching
fix: caching
fix: caching
ovflowd commentedon Nov 20, 2023
ovflowd commentedon Nov 20, 2023
I think it's important to mention that we have numerous constant files and it would make sense to have similar constants grouped together (ie. assume we have multiple constants for
distrelated things ordownload/related things, it makes sense to have all these paths and logic to be close togetherflakey5 commentedon Nov 20, 2023
Is there a reason behind why
dist: () => `${DIST_PATH_PREFIX}${url.pathname.substring('/dist'.length) || '/'}`,instead ofdist: DIST_PATH_PREFIX + (url.pathname.substring('/dist'.length) || '/'),?ovflowd commentedon Nov 20, 2023
ovflowd commentedon Nov 20, 2023
The main reasoning behind is: You don't calculate and do all these string interpolation at once...
flakey5 commentedon Nov 21, 2023
Do we want to tell clients to locally cache HEAD requests? It's what we're doing now, but given we don't cache them on the worker's end I wanted to double check
release-cloudflare-worker/src/handlers/strategies/serveFile.ts
Line 159 in 830d72a
fix: caching
fix: caching
fix: caching
fix: caching