Skip to content

Commit

Permalink
code review fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
flakey5 committed Oct 7, 2023
1 parent 4094c82 commit ffd3a46
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules/
.wrangler/
dist/
.dev.vars
.dev.vars
4 changes: 4 additions & 0 deletions src/constants/limits.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Max amount of retries for S3 requests
*/
export const S3_RETRY_LIMIT = 3;
3 changes: 2 additions & 1 deletion src/handlers/strategies/directoryListing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { getFile } from './serveFile';

// Imports the Precompiled Handlebars Template
import htmlTemplate from '../../templates/directoryListing.out.js';
import { S3_RETRY_LIMIT } from '../../constants/limits';

// Applies the Template into a Handlebars Template Function
const handleBarsTemplate = Handlebars.template(htmlTemplate);
Expand Down Expand Up @@ -120,7 +121,7 @@ async function fetchR2Result(
): Promise<ListObjectsV2CommandOutput> {
let result: ListObjectsV2CommandOutput | undefined = undefined;

let retriesRemaining = 3;
let retriesRemaining = S3_RETRY_LIMIT;
while (retriesRemaining > 0) {
try {
// Send request to R2
Expand Down
5 changes: 5 additions & 0 deletions tests/e2e/directory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ async function startS3Mock(): Promise<http.Server> {
const url = new URL(req.url!, `http://${req.headers.host}`);

let xmlFilePath = './tests/e2e/test-data/expected-s3/';

// Check if it's a path that's supposed to exist in
// later tests. If so, return a S3 response indicating that
// the path exists. Otherwise return a S3 response indicating
// that the path doesn't exist
if (
['nodejs/release/', 'nodejs/', 'metrics/'].includes(
url.searchParams.get('prefix')!
Expand Down

0 comments on commit ffd3a46

Please sign in to comment.