Skip to content

Commit 03e06b0

Browse files
authored
refactor(ts): merge initial TypeScript conversion (googleapis#334)
* refactor(ts): Typescript conversion (initial) (googleapis#255) * refactor(ts): Rename *.js to .ts * refactor(ts): setup typescript tools * refactor(ts): install available @types packages * refactor(ts): remove .js extension from imports * refactor(ts): gts fix * refactor(ts): function to arrow => * refactor(ts): for...in => for...of Object.keys(... * refactor(ts): use native `extends Error` for custom error classes ...instead of relying on package 'create-error-class' * refactor(ts): module.exports => export { ... } * refactor(ts): temporarily disable noImplicitAny before augmenting types * refactor(ts): eof \n * refactor(ts): use typescipt ~2.9.2 * Revert "refactor(ts): module.exports => export { ... }" This reverts commit 219ef2f2b4c1f423afd15246bea6735e42b15d3b. * refactor(ts): temporarily remove posttest npm script * refactor(ts): internalize class and object members into class (googleapis#260) * refactor(ts): Acl: internalize static/object properties to class * refactor(ts): Bucket: internalize static/object properties to class * refactor(ts): File: internalize static/object properties to class * refactor(ts): Iam: internalize static/object properties to class * refactor(ts): File: internalized missed properties to class * chore: update package-lock.json * refactor(ts): Storage: internalize class/object properties into class * refactor(ts): Iam: import Bucket * refactor(ts): File: internal Acl * refactor(ts): add 'any' type to suppress compiler error (googleapis#261) * refactor(ts): Channel: type cast this.metadata as any * refactor(ts): Bucket: add types to make tsc work * refactor(ts): Acl: add any types * refactor(ts): File: add any types * refactor(ts): Storage: add any types * refactor(ts): Notification: add any[] type * refactor(ts): File: add any[] type * Typescript: use ts-style exports instead of module.exports (googleapis#267) * refactor(ts): use es6/ts export in project files * refactor(ts): import from file in project * refactor(ts): export = Storage; fix import from Storage from other classes * chore: update gcs-resumable-upload to 0.11.1 * refactor(ts): misc. fixes to make tsc happy (googleapis#268) * refactor(ts): File: add optional types for uninitialized members * refactor(ts): Bucket: options is optional in constructor * refactor(ts): File: various `any` cast; optional callback? and type fixes * refactor(ts): add Acl#default as a member * refactor(ts): Bucket: various any cast; optional callback? and type fixes * refactor(ts): Notification: add any cast; optional callback? * refactor(ts): Iam: type cast any * refactor(ts): Acl.default is optional * refactor(ts): require pumpify * refactor(ts): !assert this.acl.default exists in bucket * cleanup: no longer need to set Storage.X * refactor(ts): export = Storage proxy * refactor(ts): destructure apply Proxy and call Storage with single argument * refactor(ts): fix Date comparisons * cleanup: remove ignore no-class-assign * refactor(ts): convert tests to typescript (1) (googleapis#272) * refactor(ts): Tests: *.js => *.ts * refactor(ts): add missing @types/ in tests * refactor(ts): iam use ts-style imports * refactor(ts): test/index.ts use ts-style imports * refactor(ts): test/file.ts use ts-style imports * refactor(ts): test/bucket.ts use ts-style imports * refactor(ts): test/acl.ts use ts-style imports * refactor(ts): test/acl.ts move fakes inside describe(..) So tsc won't complain we're redeclaring sth. * refactor(ts): test/channel.ts use ts-style imports * refactor(ts): test/notification.ts use ts-style imports * refactor(ts): move let Acl back to outer scope * Typescript: setup package.json and .circleci/config.yaml (googleapis#271) * refactor(ts): update package.json with ts project specify paths * refactor(ts): add tsc compile step to npm; npm run check instead of lint * refactor(ts): npm run compile comes after npm install * refactor(ts): dont need to compile ts explicitly * refactor(ts): lint should run eslint on js tests, and run gts check on ts * refactor(es6): ts-ify 2 * refactor(ts): allow implicit this as any temporarily * refactor(ts): add any-cast and optional arg? to make test/bucket.ts compile * refactor(ts): add any-cast to test/notification.ts * refactor(ts): test/file.ts: add any-casts and optional arg? to make it compile * refactor(ts): test/file.ts: Date comparisons using .valueOf() * refactor(ts): test/file.ts Request fakes uses class syntax * refactor(ts): main src is in build/ now so require('..') will not work (googleapis#286) * refactor(ts): import individual exports from @google-cloud/common (googleapis#287) * refactor(ts): make test/notification.ts pass (googleapis#290) * refactor(ts): test/notification.ts: import indiv common exports * refactor(ts): fix Notification import from named export * refactor(ts): test/iam.ts: fix proxyquire import * refactor(ts): test/channel.ts: fix proxyquire import * refactor(ts): make test/acl.ts pass (googleapis#288) * TypeScript: make test/index.ts pass (googleapis#292) * refactor(ts): Storage test: fix relative path * refactor(ts): Storage test: fix FakeChannel proxyquire * refactor(ts): test-no-cover should compile ts before running test (googleapis#289) * build: test-no-cover should compile ts before running test * refactor(ts): change npm scripts to conform to typescript best practices * refactor(ts): checkin mocha.opts and add mocha deps * cleanup(codecov): ignore build/test for code coverage (googleapis#293) * TypeScript: make Bucket test pass (googleapis#291) * refactor(ts): test/bucket: fix proxyquire import * refactor(ts): fix testdata file path * refactor(ts): test/bucket.ts: fix common util * refactor(ts): test/bucket.ts: proxyquire async via default import * refactor(ts): make test/file.ts pass (googleapis#294) * refactor(ts): assign .name property to custom File error types * refactor(ts): test/file: FakeRequest#getRequestOptions should be static * refactor(ts): resumable-upload uses es6 modules, so proxyquire as default * refactor(ts): run gts fix (googleapis#295) * refactor(ts): function to arrow => (googleapis#297) * refactor(ts): function to arrow => * style * Revert "refactor(ts): function to arrow => (googleapis#297)" (googleapis#298) This reverts commit c35e9ccccf70161ffbae2e5ba18bc06072c80f81. * refactor(ts): tests function() to arrow => (googleapis#299) * refactor(ts): function to arrow => * style * refactor(ts): test/acl.ts: replace ref `arguments` in arrow function * refactor(ts): test/bucket.ts fix arrow function `this` and `arguments` ref * refactor(ts): test/file.ts fix arrow function `this` and `arguments` ref * refactor(ts): test/iam.ts fix arrow function `this` ref * refactor(ts): tslint:disable-next-line:variable-name (googleapis#300) * Typescript: workaround explicit 'any' cast in tests (googleapis#307) * ts: avoid using extend to override request methods * ts: no allowSyntheticDefaultImports (googleapis#316) * dep: update gts@0.8 and typescript@3.0.1 * ts: no allowSyntheticDefaultImports * ts: gts fix * TypeScript: export {Storage} as named export (googleapis#327) * ts: export Storage as named export - const {Storage} = req... BREAKING CHANGE: Storage will need to be imported as a named import: const { Storage } = require('@google-cloud/storage'); Storage cannot be instantiated without new: 𝘅 const storage = Storage(); // deprecated ✔ const storage = new Storage(); * ts: fix tests now that Storage is named * ts(docs): fix all in-line samples to use named-exported Storage (googleapis#329) * ts(docs): fix all in-line samples to use named-exported Storage * ts: named Storage import in samples and system tests * dep: Use v0.21.0 of @google-cloud/common (googleapis#330) * dep: bring in nodejs-common@0.21.0 * install @google-cloud/promisify and paginator and use them * extract paginator and promisify from proxyquire of @google-cloud/common * Delete package-lock.json * ts: more fixes (googleapis#333) * ts: add interfaces to get rid of any * ts: strip any * ts: add interface * dep: upgrade @google-cloud/common to ^0.21.1 * ts: get rid of any cast in bucket.ts with types * ts: fix anys * fix remaining check issues * ts: fix test * fix: use new Storage() constructor in system-test * doc: fix init in README.md quickstart * fix: arrow functions * more arrow funcitons * add ignore no-any for now; * ts doesnt like for..in, fix it * gts fix * fix test
1 parent 6230169 commit 03e06b0

38 files changed

Lines changed: 4157 additions & 3837 deletions

handwritten/storage/.circleci/config.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
- image: 'node:6'
6060
user: node
6161
steps: &unit_tests_steps
62-
- checkout
62+
- checkout
6363
- run: &npm_install_and_link
6464
name: Install and link the module
6565
command: |-
@@ -96,7 +96,7 @@ jobs:
9696
NPM_CONFIG_PREFIX: /home/node/.npm-global
9797
- run:
9898
name: Run linting.
99-
command: npm run lint
99+
command: npm run check
100100
environment:
101101
NPM_CONFIG_PREFIX: /home/node/.npm-global
102102
docs:
@@ -172,5 +172,4 @@ jobs:
172172
steps:
173173
- checkout
174174
- run: 'echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc'
175-
- run: npm publish
176-
175+
- run: npm publish --access=public

handwritten/storage/.clang-format

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Language: JavaScript
2+
BasedOnStyle: Google
3+
ColumnLimit: 80

handwritten/storage/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Google APIs Client Libraries, in [Client Libraries Explained][explained].
6666

6767
```javascript
6868
// Imports the Google Cloud client library
69-
const Storage = require('@google-cloud/storage');
69+
const {Storage} = require('@google-cloud/storage');
7070

7171
// Your Google Cloud Platform project ID
7272
const projectId = 'YOUR_PROJECT_ID';

handwritten/storage/package.json

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
"node": ">=6.0.0"
99
},
1010
"repository": "googleapis/nodejs-storage",
11-
"main": "./src/index.js",
11+
"main": "./build/src/index.js",
12+
"types": "./build/src/index.t.ds",
1213
"files": [
13-
"src",
14+
"build/src",
1415
"AUTHORS",
1516
"CONTRIBUTORS",
1617
"COPYING"
@@ -53,19 +54,31 @@
5354
"greenkeeper[bot] <greenkeeper[bot]@users.noreply.github.com>"
5455
],
5556
"scripts": {
57+
"codecov": "nyc report --reporter=json && codecov -f .coverage/*.json",
5658
"docs": "jsdoc -c .jsdoc.js",
57-
"lint": "eslint src/ samples/ system-test/ test/",
58-
"prettier": "prettier --write src/**/*.js samples/*.js samples/**/*.js system-test/**/*.js test/**/*.js",
59-
"cover": "nyc --reporter=lcov mocha test/*.js && nyc report",
60-
"test-no-cover": "mocha test/",
61-
"test": "npm run cover",
62-
"samples-test": "npm link && cd samples/ && npm link @google-cloud/storage && npm test && cd ../",
59+
"generate-scaffolding": "repo-tools generate all && repo-tools generate lib_samples_readme -l samples/ --config ../.cloud-repo-tools.json",
6360
"system-test": "mocha system-test/ --timeout 600000",
61+
"test-only": "nyc mocha build/test",
62+
"test": "npm run test-only",
63+
"pretest-only": "npm run compile",
64+
"lint": "eslint samples/ system-test/ && gts check",
65+
"samples-test": "npm link && cd samples/ && npm link ../ & npm test && cd ../",
6466
"all-test": "npm test && npm run system-test && npm run samples-test",
65-
"generate-scaffolding": "repo-tools generate all && repo-tools generate lib_samples_readme -l samples/ --config ../.cloud-repo-tools.json"
67+
"check": "gts check",
68+
"clean": "gts clean",
69+
"compile": "tsc -p .",
70+
"fix": "gts fix",
71+
"prepare": "npm run compile"
72+
},
73+
"nyc": {
74+
"exclude": [
75+
"build/test"
76+
]
6677
},
6778
"dependencies": {
68-
"@google-cloud/common": "^0.20.0",
79+
"@google-cloud/common": "^0.21.0",
80+
"@google-cloud/paginator": "^0.1.0",
81+
"@google-cloud/promisify": "^0.3.0",
6982
"arrify": "^1.0.0",
7083
"async": "^2.0.1",
7184
"compressible": "^2.0.12",
@@ -90,11 +103,30 @@
90103
"devDependencies": {
91104
"@google-cloud/nodejs-repo-tools": "^2.2.3",
92105
"@google-cloud/pubsub": "*",
106+
"@types/arrify": "^1.0.4",
107+
"@types/assert": "0.0.31",
108+
"@types/async": "^2.0.49",
109+
"@types/compressible": "^2.0.0",
110+
"@types/concat-stream": "^1.6.0",
111+
"@types/extend": "^3.0.0",
112+
"@types/is": "0.0.20",
113+
"@types/mime": "^2.0.0",
114+
"@types/mime-types": "^2.1.0",
115+
"@types/mocha": "^5.2.3",
116+
"@types/once": "^1.4.0",
117+
"@types/proxyquire": "^1.3.28",
118+
"@types/pumpify": "^1.4.1",
119+
"@types/request": "^2.47.1",
120+
"@types/through2": "^2.0.33",
121+
"@types/tmp": "0.0.33",
122+
"@types/xdg-basedir": "^2.0.0",
93123
"codecov": "^3.0.0",
94124
"eslint": "^5.0.0",
95125
"eslint-config-prettier": "^3.0.0",
96126
"eslint-plugin-node": "^7.0.0",
97127
"eslint-plugin-prettier": "^2.3.1",
128+
"gts": "^0.8.0",
129+
"hard-rejection": "^1.0.0",
98130
"ink-docstrap": "https://github.com/docstrap/docstrap/tarball/master",
99131
"intelli-espower-loader": "^1.0.1",
100132
"jsdoc": "^3.5.4",
@@ -107,7 +139,9 @@
107139
"propprop": "^0.3.0",
108140
"proxyquire": "^2.0.0",
109141
"semistandard": "^12.0.0",
142+
"source-map-support": "^0.5.6",
110143
"tmp": "^0.0.33",
144+
"typescript": "^3.0.1",
111145
"uuid": "^3.1.0"
112146
}
113147
}

handwritten/storage/samples/acl.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
function printBucketAcl(bucketName) {
2727
// [START storage_print_bucket_acl]
2828
// Imports the Google Cloud client library
29-
const Storage = require('@google-cloud/storage');
29+
const {Storage} = require('@google-cloud/storage');
3030

3131
// Creates a client
3232
const storage = new Storage();
@@ -56,7 +56,7 @@ function printBucketAcl(bucketName) {
5656
function printBucketAclForUser(bucketName, userEmail) {
5757
// [START storage_print_bucket_acl_for_user]
5858
// Imports the Google Cloud client library
59-
const Storage = require('@google-cloud/storage');
59+
const {Storage} = require('@google-cloud/storage');
6060

6161
// Creates a client
6262
const storage = new Storage();
@@ -90,7 +90,7 @@ function printBucketAclForUser(bucketName, userEmail) {
9090
function addBucketOwner(bucketName, userEmail) {
9191
// [START storage_add_bucket_owner]
9292
// Imports the Google Cloud client library
93-
const Storage = require('@google-cloud/storage');
93+
const {Storage} = require('@google-cloud/storage');
9494

9595
// Creates a client
9696
const storage = new Storage();
@@ -122,7 +122,7 @@ function addBucketOwner(bucketName, userEmail) {
122122
function removeBucketOwner(bucketName, userEmail) {
123123
// [START storage_remove_bucket_owner]
124124
// Imports the Google Cloud client library
125-
const Storage = require('@google-cloud/storage');
125+
const {Storage} = require('@google-cloud/storage');
126126

127127
// Creates a client
128128
const storage = new Storage();
@@ -151,7 +151,7 @@ function removeBucketOwner(bucketName, userEmail) {
151151
function addBucketDefaultOwner(bucketName, userEmail) {
152152
// [START storage_add_bucket_default_owner]
153153
// Imports the Google Cloud client library
154-
const Storage = require('@google-cloud/storage');
154+
const {Storage} = require('@google-cloud/storage');
155155

156156
// Creates a client
157157
const storage = new Storage();
@@ -183,7 +183,7 @@ function addBucketDefaultOwner(bucketName, userEmail) {
183183
function removeBucketDefaultOwner(bucketName, userEmail) {
184184
// [START storage_remove_bucket_default_owner]
185185
// Imports the Google Cloud client library
186-
const Storage = require('@google-cloud/storage');
186+
const {Storage} = require('@google-cloud/storage');
187187

188188
// Creates a client
189189
const storage = new Storage();
@@ -212,7 +212,7 @@ function removeBucketDefaultOwner(bucketName, userEmail) {
212212
function printFileAcl(bucketName, filename) {
213213
// [START storage_print_file_acl]
214214
// Imports the Google Cloud client library
215-
const Storage = require('@google-cloud/storage');
215+
const {Storage} = require('@google-cloud/storage');
216216

217217
// Creates a client
218218
const storage = new Storage();
@@ -244,7 +244,7 @@ function printFileAcl(bucketName, filename) {
244244
function printFileAclForUser(bucketName, filename, userEmail) {
245245
// [START storage_print_file_acl_for_user]
246246
// Imports the Google Cloud client library
247-
const Storage = require('@google-cloud/storage');
247+
const {Storage} = require('@google-cloud/storage');
248248

249249
// Creates a client
250250
const storage = new Storage();
@@ -280,7 +280,7 @@ function printFileAclForUser(bucketName, filename, userEmail) {
280280
function addFileOwner(bucketName, filename, userEmail) {
281281
// [START storage_add_file_owner]
282282
// Imports the Google Cloud client library
283-
const Storage = require('@google-cloud/storage');
283+
const {Storage} = require('@google-cloud/storage');
284284

285285
// Creates a client
286286
const storage = new Storage();
@@ -312,7 +312,7 @@ function addFileOwner(bucketName, filename, userEmail) {
312312
// [START storage_remove_file_owner]
313313
function removeFileOwner(bucketName, filename, userEmail) {
314314
// Imports the Google Cloud client library
315-
const Storage = require('@google-cloud/storage');
315+
const {Storage} = require('@google-cloud/storage');
316316

317317
// Creates a client
318318
const storage = new Storage();

handwritten/storage/samples/buckets.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
function createBucket(bucketName) {
2727
// [START storage_create_bucket]
2828
// Imports the Google Cloud client library
29-
const Storage = require('@google-cloud/storage');
29+
const {Storage} = require('@google-cloud/storage');
3030

3131
// Creates a client
3232
const storage = new Storage();
@@ -54,7 +54,7 @@ function createBucket(bucketName) {
5454
function listBuckets() {
5555
// [START storage_list_buckets]
5656
// Imports the Google Cloud client library
57-
const Storage = require('@google-cloud/storage');
57+
const {Storage} = require('@google-cloud/storage');
5858

5959
// Creates a client
6060
const storage = new Storage();
@@ -79,7 +79,7 @@ function listBuckets() {
7979
function deleteBucket(bucketName) {
8080
// [START storage_delete_bucket]
8181
// Imports the Google Cloud client library
82-
const Storage = require('@google-cloud/storage');
82+
const {Storage} = require('@google-cloud/storage');
8383

8484
// Creates a client
8585
const storage = new Storage();
@@ -105,7 +105,7 @@ function deleteBucket(bucketName) {
105105
function enableDefaultKMSKey(bucketName, defaultKmsKeyName) {
106106
// [START storage_set_bucket_default_kms_key]
107107
// Imports the Google Cloud client library
108-
const Storage = require('@google-cloud/storage');
108+
const {Storage} = require('@google-cloud/storage');
109109

110110
// Creates a client
111111
const storage = new Storage();

handwritten/storage/samples/encryption.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function generateEncryptionKey() {
5151
function uploadEncryptedFile(bucketName, srcFilename, destFilename, key) {
5252
// [START storage_upload_encrypted_file]
5353
// Imports the Google Cloud client library
54-
const Storage = require('@google-cloud/storage');
54+
const {Storage} = require('@google-cloud/storage');
5555

5656
// Creates a client
5757
const storage = new Storage();
@@ -93,7 +93,7 @@ function uploadEncryptedFile(bucketName, srcFilename, destFilename, key) {
9393
function downloadEncryptedFile(bucketName, srcFilename, destFilename, key) {
9494
// [START storage_download_encrypted_file]
9595
// Imports the Google Cloud client library
96-
const Storage = require('@google-cloud/storage');
96+
const {Storage} = require('@google-cloud/storage');
9797

9898
// Creates a client
9999
const storage = new Storage();
@@ -132,7 +132,7 @@ function downloadEncryptedFile(bucketName, srcFilename, destFilename, key) {
132132
function rotateEncryptionKey(bucketName, fileName, oldKey, newKey) {
133133
// [START storage_rotate_encryption_key]
134134
// Imports the Google Cloud client library
135-
const Storage = require('@google-cloud/storage');
135+
const {Storage} = require('@google-cloud/storage');
136136

137137
// Creates a client
138138
const storage = new Storage();

handwritten/storage/samples/files.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
function listFiles(bucketName) {
2727
// [START storage_list_files]
2828
// Imports the Google Cloud client library
29-
const Storage = require('@google-cloud/storage');
29+
const {Storage} = require('@google-cloud/storage');
3030

3131
// Creates a client
3232
const storage = new Storage();
@@ -57,7 +57,7 @@ function listFiles(bucketName) {
5757
function listFilesByPrefix(bucketName, prefix, delimiter) {
5858
// [START storage_list_files_with_prefix]
5959
// Imports the Google Cloud client library
60-
const Storage = require('@google-cloud/storage');
60+
const {Storage} = require('@google-cloud/storage');
6161

6262
// Creates a client
6363
const storage = new Storage();
@@ -117,7 +117,7 @@ function listFilesByPrefix(bucketName, prefix, delimiter) {
117117
function uploadFile(bucketName, filename) {
118118
// [START storage_upload_file]
119119
// Imports the Google Cloud client library
120-
const Storage = require('@google-cloud/storage');
120+
const {Storage} = require('@google-cloud/storage');
121121

122122
// Creates a client
123123
const storage = new Storage();
@@ -153,7 +153,7 @@ function uploadFile(bucketName, filename) {
153153
function uploadFileWithKmsKey(bucketName, filename, kmsKeyName) {
154154
// [START storage_upload_with_kms_key]
155155
// Imports the Google Cloud client library
156-
const Storage = require('@google-cloud/storage');
156+
const {Storage} = require('@google-cloud/storage');
157157

158158
// Creates a client
159159
const storage = new Storage();
@@ -183,7 +183,7 @@ function uploadFileWithKmsKey(bucketName, filename, kmsKeyName) {
183183
function downloadFile(bucketName, srcFilename, destFilename) {
184184
// [START storage_download_file]
185185
// Imports the Google Cloud client library
186-
const Storage = require('@google-cloud/storage');
186+
const {Storage} = require('@google-cloud/storage');
187187

188188
// Creates a client
189189
const storage = new Storage();
@@ -219,7 +219,7 @@ function downloadFile(bucketName, srcFilename, destFilename) {
219219
function deleteFile(bucketName, filename) {
220220
// [START storage_delete_file]
221221
// Imports the Google Cloud client library
222-
const Storage = require('@google-cloud/storage');
222+
const {Storage} = require('@google-cloud/storage');
223223

224224
// Creates a client
225225
const storage = new Storage();
@@ -247,7 +247,7 @@ function deleteFile(bucketName, filename) {
247247
function getMetadata(bucketName, filename) {
248248
// [START storage_get_metadata]
249249
// Imports the Google Cloud client library
250-
const Storage = require('@google-cloud/storage');
250+
const {Storage} = require('@google-cloud/storage');
251251

252252
// Creates a client
253253
const storage = new Storage();
@@ -297,7 +297,7 @@ function getMetadata(bucketName, filename) {
297297
function makePublic(bucketName, filename) {
298298
// [START storage_make_public]
299299
// Imports the Google Cloud client library
300-
const Storage = require('@google-cloud/storage');
300+
const {Storage} = require('@google-cloud/storage');
301301

302302
// Creates a client
303303
const storage = new Storage();
@@ -325,7 +325,7 @@ function makePublic(bucketName, filename) {
325325
function generateSignedUrl(bucketName, filename) {
326326
// [START storage_generate_signed_url]
327327
// Imports the Google Cloud client library
328-
const Storage = require('@google-cloud/storage');
328+
const {Storage} = require('@google-cloud/storage');
329329

330330
// Creates a client
331331
const storage = new Storage();
@@ -361,7 +361,7 @@ function generateSignedUrl(bucketName, filename) {
361361
function moveFile(bucketName, srcFilename, destFilename) {
362362
// [START storage_move_file]
363363
// Imports the Google Cloud client library
364-
const Storage = require('@google-cloud/storage');
364+
const {Storage} = require('@google-cloud/storage');
365365

366366
// Creates a client
367367
const storage = new Storage();
@@ -392,7 +392,7 @@ function moveFile(bucketName, srcFilename, destFilename) {
392392
function copyFile(srcBucketName, srcFilename, destBucketName, destFilename) {
393393
// [START storage_copy_file]
394394
// Imports the Google Cloud client library
395-
const Storage = require('@google-cloud/storage');
395+
const {Storage} = require('@google-cloud/storage');
396396

397397
// Creates a client
398398
const storage = new Storage();

0 commit comments

Comments
 (0)