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

Commit 1506a1e

Browse files
committed
feat: use small HTTP dependency
1 parent 9e3cc03 commit 1506a1e

6 files changed

Lines changed: 21 additions & 12 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@
9494
"mime-types": "^2.0.8",
9595
"once": "^1.3.1",
9696
"pumpify": "^1.5.1",
97-
"request": "^2.88.0",
9897
"snakeize": "^0.1.0",
9998
"stream-events": "^1.0.1",
99+
"teeny-request": "^3.10.0",
100100
"through2": "^2.0.0",
101101
"xdg-basedir": "^3.0.0"
102102
},

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';
@@ -703,7 +704,7 @@ class Bucket extends ServiceObject {
703704
id: name,
704705
createMethod: storage.createBucket.bind(storage),
705706
methods,
706-
requestModule: request,
707+
requestModule: teenyRequest as typeof request,
707708
});
708709

709710
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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +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';
4140
import * as http from 'http';
41+
import * as r from 'request'; // Only for type declarations.
42+
import {teenyRequest} from 'teeny-request';
4243

4344
import {Storage} from '.';
4445
import {Bucket} from './bucket';
@@ -471,7 +472,7 @@ class File extends ServiceObject {
471472
parent: bucket,
472473
baseUrl: '/o',
473474
id: encodeURIComponent(name),
474-
requestModule: r,
475+
requestModule: teenyRequest as typeof r,
475476
});
476477

477478
this.bucket = bucket;
@@ -2893,7 +2894,7 @@ class File extends ServiceObject {
28932894
},
28942895
metadata: options.metadata,
28952896
request: reqOpts,
2896-
requestModule: r,
2897+
requestModule: teenyRequest as typeof r,
28972898
});
28982899
}
28992900
}

src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ import {Service, GoogleAuthOptions, CreateOptions} 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';
@@ -258,7 +259,7 @@ class Storage extends Service {
258259
'https://www.googleapis.com/auth/devstorage.full_control',
259260
],
260261
packageJson: require('../../package.json'),
261-
requestModule: request,
262+
requestModule: teenyRequest as typeof request,
262263
};
263264

264265
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

0 commit comments

Comments
 (0)