Repository: spotify/backstage
File: plugins/techdocs-node/src/stages/publish/awsS3.ts (TypeScript)

Code before:
    const forcePathStyle = config.getOptionalBoolean(
      'techdocs.publisher.awsS3.s3ForcePathStyle',
    );

    // AWS MAX ATTEMPTS is an optional config. If missing, default value of 3 is used
    const maxAttempts = config.getOptionalNumber(
      'techdocs.publisher.awsS3.maxAttempts',
    );

    const storageClient = new S3Client({
      customUserAgent: 'backstage-aws-techdocs-s3-publisher',
      credentialDefaultProvider: () => sdkCredentialProvider,
      ...(region && { region }),
      ...(endpoint && { endpoint }),
      ...(forcePathStyle && { forcePathStyle }),
      // Enhanced retry configuration for better reliability
      maxAttempts: maxAttempts || 5,
      retryMode: 'adaptive',
      ...(httpsProxy && {
        requestHandler: new NodeHttpHandler({
          httpsAgent: new HttpsProxyAgent({ proxy: httpsProxy }),
          // Enhanced connection setting for large file uploads
          connectionTimeout: 60000,
          socketTimeout: 120000,
        }),
      }),
      // Add default request handler with enhanced timeouts if no proxy
      ...(!httpsProxy && {
        requestHandler: new NodeHttpHandler({
          connectionTimeout: 60000,
          socketTimeout: 120000,
        }),
      }),
    });

    const legacyPathCasing =
      config.getOptionalBoolean(
        'techdocs.legacyUseCaseSensitiveTripletPaths',
      ) || false;

    return new AwsS3Publish({
      storageClient,
      bucketName,
      bucketRootPath,
      legacyPathCasing,
      logger,
      sse,
      maxAttempts: maxAttempts || 5,
    });
  }


Review comment (suggestion):
this could be simplified to

```ts
requestHandler: new NodeHttpHandler({
  ...(httpsProxy && { httpsAgent: new HttpsProxyAgent({ proxy: httpsProxy }) }),
  connectionTimeout: 60000,
  socketTimeout: 120000,
}),
```

to not have to repeat yourself

Code after:
    const forcePathStyle = config.getOptionalBoolean(
      'techdocs.publisher.awsS3.s3ForcePathStyle',
    );

    // AWS MAX ATTEMPTS is an optional config. If missing, default value of 5 is used
    const maxAttempts = config.getOptionalNumber(
      'techdocs.publisher.awsS3.maxAttempts',
    );

    const storageClient = new S3Client({
      customUserAgent: 'backstage-aws-techdocs-s3-publisher',
      credentialDefaultProvider: () => sdkCredentialProvider,
      ...(region && { region }),
      ...(endpoint && { endpoint }),
      ...(forcePathStyle && { forcePathStyle }),
      // Enhanced retry configuration for better reliability
      maxAttempts: maxAttempts || 5,
      retryMode: 'adaptive',
      // Enhanced connection settings for large file uploads
      requestHandler: new NodeHttpHandler({
        ...(httpsProxy && {
          httpsAgent: new HttpsProxyAgent({ proxy: httpsProxy }),
        }),
        connectionTimeout: 60000,
        socketTimeout: 120000,
      }),
    });

    const legacyPathCasing =
      config.getOptionalBoolean(
        'techdocs.legacyUseCaseSensitiveTripletPaths',
      ) || false;

    return new AwsS3Publish({
      storageClient,
      bucketName,
      bucketRootPath,
      legacyPathCasing,
      logger,
      sse,
      maxAttempts: maxAttempts || 5,
    });
  }

  private static buildStaticCredentials(
    accessKeyId: string,
    secretAccessKey: string,
  ): AwsCredentialIdentityProvider {
    return async () => {
      return Promise.resolve({
        accessKeyId,