From 7853566d44cb71da47e235068f2ec306988b0967 Mon Sep 17 00:00:00 2001 From: Raushan kumar Date: Tue, 13 Jan 2026 13:51:44 +0000 Subject: [PATCH] fix(samples): replace server-destroy with native closeAllConnections --- samples/oauth2.js | 12 ++++++------ samples/package.json | 5 ++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/samples/oauth2.js b/samples/oauth2.js index 00a51c33814..d581214e880 100644 --- a/samples/oauth2.js +++ b/samples/oauth2.js @@ -17,8 +17,7 @@ const fs = require('fs'); const path = require('path'); const http = require('http'); const url = require('url'); -const opn = require('open'); -const destroyer = require('server-destroy'); +const open = require('open'); const {google} = require('googleapis'); const people = google.people('v1'); @@ -63,9 +62,10 @@ async function authenticate(scopes) { const qs = new url.URL(req.url, 'http://localhost:3000') .searchParams; res.end('Authentication successful! Please return to the console.'); - server.destroy(); + server.closeAllConnections(); + server.close(); const {tokens} = await oauth2Client.getToken(qs.get('code')); - oauth2Client.credentials = tokens; // eslint-disable-line require-atomic-updates + oauth2Client.credentials = tokens; resolve(oauth2Client); } } catch (e) { @@ -74,9 +74,9 @@ async function authenticate(scopes) { }) .listen(3000, () => { // open the browser to the authorize url to start the workflow - opn(authorizeUrl, {wait: false}).then(cp => cp.unref()); + open(authorizeUrl, {wait: false}).then(cp => cp.unref()); }); - destroyer(server); + }); } diff --git a/samples/package.json b/samples/package.json index 85b14b39d71..ca73a090b70 100644 --- a/samples/package.json +++ b/samples/package.json @@ -20,8 +20,7 @@ "googleapis": "^170.0.0", "googleapis-common": "^8.0.2-rc.0", "nconf": "^0.13.0", - "open": "^8.0.0", - "server-destroy": "^1.0.1" + "open": "^8.0.0" }, "devDependencies": { "chai": "^4.2.0", @@ -31,4 +30,4 @@ "proxyquire": "^2.1.3", "typescript": "^4.6.4" } -} \ No newline at end of file +}