Skip to content

Commit

Permalink
Merge branch 'mdt/max-content' into mdt/restricted-content-type
Browse files Browse the repository at this point in the history
  • Loading branch information
mdtanrikulu committed Sep 26, 2024
2 parents 54fcdfe + 3614691 commit 4e8c8e2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export class AvatarResolver implements AvatarResolver {
if (options?.agents) {
createAgentAdapter(fetch, options?.agents);
}

if (options?.maxContentLength && options?.maxContentLength > 0) {
fetch.defaults.maxContentLength = options?.maxContentLength;
}
}

async getMetadata(ens: string, key: string = 'avatar') {
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface AvatarResolverOpts {
apiKey?: MarketplaceAPIKey;
urlDenyList?: string[];
agents?: AxiosAgents;
maxContentLength?: number;
}

export interface AvatarRequestOpts {
Expand Down
3 changes: 3 additions & 0 deletions src/utils/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ export function createCacheAdapter(fetch: Axios, ttl: number) {
function createFetcher({
ttl,
agents,
maxContentLength

Check failure on line 26 in src/utils/fetch.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.x and ubuntu-latest

Insert `,`

Check failure on line 26 in src/utils/fetch.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 18.x and macOS-latest

Insert `,`

Check failure on line 26 in src/utils/fetch.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 20.x and macOS-latest

Insert `,`
}: {
ttl?: number;
agents?: AxiosAgents;
maxContentLength?: number;
}) {
const _fetch = axios.create({
proxy: false,
...(maxContentLength && { maxContentLength }),
});
if (ttl && ttl > 0) {
createCacheAdapter(_fetch, ttl);
Expand Down

0 comments on commit 4e8c8e2

Please sign in to comment.