Skip to content

Commit 6f06e53

Browse files
committed
upgrade node-fetch v3 and remove uuid
1 parent 8db2694 commit 6f06e53

File tree

5 files changed

+19
-20
lines changed

5 files changed

+19
-20
lines changed

src/TeenyStatistics.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export class TeenyStatistics {
153153
this._options.concurrentRequests +
154154
'. Use the TEENY_REQUEST_WARN_CONCURRENT_REQUESTS environment ' +
155155
'variable or the concurrentRequests option of teeny-request to ' +
156-
'increase or disable (0) this warning.',
156+
'increase or disable (0) this warning.'
157157
);
158158
warning.type = TeenyStatisticsWarning.CONCURRENT_REQUESTS;
159159
warning.value = this._concurrentRequests;
@@ -187,7 +187,7 @@ export class TeenyStatistics {
187187
let concurrentRequests = this.DEFAULT_WARN_CONCURRENT_REQUESTS;
188188

189189
const envConcurrentRequests = Number(
190-
process.env.TEENY_REQUEST_WARN_CONCURRENT_REQUESTS,
190+
process.env.TEENY_REQUEST_WARN_CONCURRENT_REQUESTS
191191
);
192192
if (diConcurrentRequests !== undefined) {
193193
concurrentRequests = diConcurrentRequests;

src/agents.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function shouldUseProxyForURI(uri: string): boolean {
6666
*/
6767
export function getAgent(
6868
uri: string,
69-
reqOpts: Options,
69+
reqOpts: Options
7070
): HttpAnyAgent | undefined {
7171
const isHttp = uri.startsWith('http://');
7272
const proxy =

src/index.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {Agent, AgentOptions as HttpsAgentOptions} from 'https';
1919
import {AgentOptions as HttpAgentOptions} from 'http';
2020
import type * as f from 'node-fetch' with {'resolution-mode': 'import'};
2121
import {PassThrough, Readable, pipeline} from 'stream';
22-
import * as uuid from 'uuid';
2322
import {getAgent} from './agents';
2423
import {TeenyStatistics} from './TeenyStatistics';
2524
// eslint-disable-next-line @typescript-eslint/no-var-requires
@@ -213,7 +212,7 @@ function teenyRequest(
213212
// TODO: add support for multipart uploads through streaming
214213
throw new Error('Multipart without callback is not implemented.');
215214
}
216-
const boundary: string = uuid.v4();
215+
const boundary: string = globalThis.crypto?.randomUUID();
217216
(options.headers as Headers)['Content-Type'] =
218217
`multipart/related; boundary=${boundary}`;
219218
options.body = createMultipartStream(boundary, multipart);

test/TeenyStatistics.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ describe('TeenyStatistics', () => {
6565
it('should have default concurrent requests', () => {
6666
assert.strictEqual(
6767
TeenyStatistics.DEFAULT_WARN_CONCURRENT_REQUESTS,
68-
5000,
68+
5000
6969
);
7070
});
7171

@@ -231,8 +231,8 @@ describe('TeenyStatistics', () => {
231231
t.requestStarting();
232232
assert(
233233
emitWarnStub.calledOnceWith(
234-
sinon.match.instanceOf(TeenyStatisticsWarning),
235-
),
234+
sinon.match.instanceOf(TeenyStatisticsWarning)
235+
)
236236
);
237237
});
238238

@@ -246,8 +246,8 @@ describe('TeenyStatistics', () => {
246246
t.requestStarting();
247247
assert(
248248
emitWarnStub.calledOnceWith(
249-
sinon.match.instanceOf(TeenyStatisticsWarning),
250-
),
249+
sinon.match.instanceOf(TeenyStatisticsWarning)
250+
)
251251
);
252252

253253
// shouldn't emit on the next call (i.e. still greater than threshold)
@@ -271,8 +271,8 @@ describe('TeenyStatistics', () => {
271271
t.requestStarting();
272272
assert(
273273
emitWarnStub.calledOnceWith(
274-
sinon.match.instanceOf(TeenyStatisticsWarning),
275-
),
274+
sinon.match.instanceOf(TeenyStatisticsWarning)
275+
)
276276
);
277277

278278
// let's bring the counter back down
@@ -298,7 +298,7 @@ describe('TeenyStatistics', () => {
298298
assert.strictEqual(warning.value, 5e3);
299299
assert.strictEqual(
300300
warning.type,
301-
TeenyStatisticsWarning.CONCURRENT_REQUESTS,
301+
TeenyStatisticsWarning.CONCURRENT_REQUESTS
302302
);
303303
});
304304

@@ -311,15 +311,15 @@ describe('TeenyStatistics', () => {
311311
const errStr: string = emitWarnStub.firstCall.args[0].toString();
312312
assert(
313313
errStr.includes('Possible excessive concurrent requests detected.'),
314-
'describes the nature of the warning',
314+
'describes the nature of the warning'
315315
);
316316
assert(
317317
errStr.includes('TEENY_REQUEST_WARN_CONCURRENT_REQUESTS'),
318-
'mentions env var',
318+
'mentions env var'
319319
);
320320
assert(
321321
errStr.includes('concurrentRequests'),
322-
'mentions concurrentRequests option',
322+
'mentions concurrentRequests option'
323323
);
324324
assert(errStr.search(/\b0\b/) !== -1, 'mentions 0');
325325
});

test/agents.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ describe('agents', () => {
211211
maxSockets: 1000,
212212
},
213213
},
214-
defaultOptions,
214+
defaultOptions
215215
);
216216
const agent = getAgent(uri, options);
217217
assert.strictEqual(agent!.maxSockets, 1000);
@@ -224,7 +224,7 @@ describe('agents', () => {
224224
maxSockets: 1000,
225225
},
226226
},
227-
defaultOptions,
227+
defaultOptions
228228
);
229229
const agent = getAgent(uri, options);
230230
assert.strictEqual(agent, undefined);
@@ -243,7 +243,7 @@ describe('agents', () => {
243243
maxSockets: 1000,
244244
},
245245
},
246-
defaultOptions,
246+
defaultOptions
247247
);
248248
const agent = getAgent(uri, options);
249249
assert.strictEqual(agent!.maxSockets, 1000);
@@ -256,7 +256,7 @@ describe('agents', () => {
256256
maxSockets: 1000,
257257
},
258258
},
259-
defaultOptions,
259+
defaultOptions
260260
);
261261
const agent = getAgent(uri, options);
262262
assert.strictEqual(agent, undefined);

0 commit comments

Comments
 (0)