Skip to content

Commit

Permalink
switch to gunzipSync for intercepted request
Browse files Browse the repository at this point in the history
  • Loading branch information
zemberdotnet committed Oct 16, 2023
1 parent 0bf5dc6 commit 646770d
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions packages/integration-sdk-cli/src/__tests__/util/synchronization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
SynchronizationJob,
SynchronizationJobStatus,
} from '@jupiterone/integration-sdk-core';
import { gunzip } from 'zlib';
import { gunzipSync } from 'zlib';

interface SetupOptions {
baseUrl: string;
Expand Down Expand Up @@ -38,10 +38,9 @@ export function setupSynchronizerApi({
.post(`${baseUrl}/persister/synchronization/jobs/${job.id}/entities`)
.intercept((req, res) => {
allowCrossOrigin(req, res);
gunzip(Buffer.from(req.body!), (err, data) => {
if (err) throw err;
job.numEntitiesUploaded += JSON.parse(data.toString()).entities.length;
});
const result = gunzipSync(Buffer.from(req.body!));
const data = JSON.parse(result.toString());
job.numEntitiesUploaded += data.entities.length;
res.status(200).json({ job });
});

Expand All @@ -56,12 +55,9 @@ export function setupSynchronizerApi({
.post(`${baseUrl}/persister/synchronization/jobs/${job.id}/relationships`)
.intercept((req, res) => {
allowCrossOrigin(req, res);
gunzip(Buffer.from(req.body!), (err, data) => {
if (err) throw err;
job.numRelationshipsUploaded += JSON.parse(
data.toString(),
).relationships.length;
});
const result = gunzipSync(Buffer.from(req.body!));
const data = JSON.parse(result.toString());
job.numRelationshipsUploaded += data.relationships.length;
res.status(200).json({ job });
});

Expand Down

0 comments on commit 646770d

Please sign in to comment.