Skip to content
This repository was archived by the owner on Mar 3, 2026. It is now read-only.

Commit 46883d5

Browse files
committed
feat: use small HTTP dependency
1 parent ed2e587 commit 46883d5

7 files changed

Lines changed: 23 additions & 14 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@
9292
"mime-types": "^2.0.8",
9393
"once": "^1.3.1",
9494
"pumpify": "^1.5.1",
95-
"request": "^2.88.0",
9695
"snakeize": "^0.1.0",
9796
"stream-events": "^1.0.1",
97+
"teeny-request": "^3.10.0",
9898
"through2": "^2.0.0",
9999
"xdg-basedir": "^3.0.0"
100100
},

src/bucket.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ import * as is from 'is';
2727
import * as mime from 'mime-types';
2828
import * as path from 'path';
2929
const snakeize = require('snakeize');
30-
import * as request from 'request';
30+
import * as request from 'request'; // Only for type declarations.
31+
import {teenyRequest} from 'teeny-request';
3132

3233
import {Acl} from './acl';
3334
import {Channel} from './channel';
@@ -702,7 +703,7 @@ class Bucket extends ServiceObject {
702703
id: name,
703704
createMethod: storage.createBucket.bind(storage),
704705
methods,
705-
requestModule: request,
706+
requestModule: teenyRequest as typeof request,
706707
});
707708

708709
this.name = name;

src/channel.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818

1919
import {ServiceObject, util} from '@google-cloud/common';
2020
import {promisifyAll} from '@google-cloud/promisify';
21-
import * as request from 'request';
21+
import * as request from 'request'; // Only for type declarations.
22+
import {teenyRequest} from 'teeny-request';
23+
2224
import {Storage} from '.';
2325
import {Response} from 'request';
2426

@@ -31,6 +33,7 @@ export interface StopCallback {
3133
(err: Error|null, apiResponse?: request.Response): void;
3234
}
3335

36+
3437
/**
3538
* Create a channel object to interact with a Cloud Storage channel.
3639
*
@@ -60,7 +63,7 @@ class Channel extends ServiceObject {
6063
methods: {
6164
// Only need `request`.
6265
},
63-
requestModule: request,
66+
requestModule: teenyRequest as typeof request,
6467
};
6568

6669
super(config);

src/file.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ import * as through from 'through2';
3737
import * as xdgBasedir from 'xdg-basedir';
3838
import * as zlib from 'zlib';
3939
import * as url from 'url';
40-
import * as r from 'request';
40+
import * as r from 'request'; // Only for type declarations.
41+
import {teenyRequest} from 'teeny-request';
42+
4143

4244
import {Storage} from '.';
4345
import {Bucket} from './bucket';
@@ -273,7 +275,7 @@ class File extends ServiceObject {
273275
parent: bucket,
274276
baseUrl: '/o',
275277
id: encodeURIComponent(name),
276-
requestModule: r,
278+
requestModule: teenyRequest as typeof r,
277279
});
278280

279281
this.bucket = bucket;
@@ -2630,7 +2632,7 @@ class File extends ServiceObject {
26302632
},
26312633
metadata: options.metadata,
26322634
request: reqOpts,
2633-
requestModule: r,
2635+
requestModule: teenyRequest as typeof r,
26342636
});
26352637
}
26362638
}

src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ import {Service, GoogleAuthOptions} from '@google-cloud/common';
2121
import {paginator} from '@google-cloud/paginator';
2222
import {promisifyAll} from '@google-cloud/promisify';
2323
import * as extend from 'extend';
24-
import * as request from 'request';
24+
import * as request from 'request'; // Only for type declarations.
25+
import {teenyRequest} from 'teeny-request';
2526

2627
import {Bucket} from './bucket';
2728
import {Channel} from './channel';
@@ -256,7 +257,7 @@ class Storage extends Service {
256257
'https://www.googleapis.com/auth/devstorage.full_control',
257258
],
258259
packageJson: require('../../package.json'),
259-
requestModule: request,
260+
requestModule: teenyRequest as typeof request,
260261
};
261262

262263
super(config, options);

src/notification.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
import {ServiceObject, util, ApiError, GetMetadataCallback} from '@google-cloud/common';
2020
import {promisifyAll} from '@google-cloud/promisify';
2121
import * as is from 'is';
22-
import * as request from 'request';
22+
import * as request from 'request'; // Only for type declarations.
23+
import {teenyRequest} from 'teeny-request';
24+
2325
import {Bucket} from './bucket';
2426
import {ResponseBody} from '@google-cloud/common/build/src/util';
2527

@@ -88,6 +90,7 @@ export interface DeleteNotificationCallback {
8890
(err: Error|null, apiResponse?: request.Response): void;
8991
}
9092

93+
9194
/**
9295
* A Notification object is created from your {@link Bucket} object using
9396
* {@link Bucket#notification}. Use it to interact with Cloud Pub/Sub
@@ -191,7 +194,7 @@ class Notification extends ServiceObject {
191194
id: id.toString(),
192195
createMethod: bucket.createNotification.bind(bucket),
193196
methods,
194-
requestModule: request,
197+
requestModule: teenyRequest as typeof request,
195198
});
196199
}
197200

system-test/storage.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,11 @@ const path = require('path');
2828
const through = require('through2');
2929
const tmp = require('tmp');
3030
const uuid = require('uuid');
31-
31+
const PubSub = require('@google-cloud/pubsub');
3232
const util = require('@google-cloud/common').util;
3333

3434
const {Storage} = require('../');
3535
const Bucket = Storage.Bucket;
36-
const PubSub = require('@google-cloud/pubsub');
3736

3837
describe('storage', function() {
3938
const USER_ACCOUNT = 'user-spsawchuk@gmail.com';

0 commit comments

Comments
 (0)