Skip to content

Commit

Permalink
Merge pull request #16 from p-fedyukovich/feature/bump-deps
Browse files Browse the repository at this point in the history
feat: bumped nestjs and pubsub
  • Loading branch information
p-fedyukovich authored Sep 28, 2022
2 parents cc01e4c + 5b331f5 commit 47b1833
Show file tree
Hide file tree
Showing 6 changed files with 636 additions and 405 deletions.
10 changes: 5 additions & 5 deletions lib/gc-pubsub.client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('GCPubSubClient', () => {
topicMock = {
create: sandbox.stub().resolves(),
flush: sandbox.stub().callsFake((callback) => callback()),
publishJSON: sandbox.stub().resolves(),
publishMessage: sandbox.stub().resolves(),
subscription: sandbox.stub().returns(subscriptionMock),
};

Expand Down Expand Up @@ -103,8 +103,8 @@ describe('GCPubSubClient', () => {
});
it('should send message to a proper topic', () => {
client['publish'](msg, () => {
expect(topicMock.publishJSON.called).to.be.true;
expect(topicMock.publishJSON.getCall(0).args[0]).to.be.eql(msg);
expect(topicMock.publishMessage.called).to.be.true;
expect(topicMock.publishMessage.getCall(0).args[0].json).to.be.eql(msg);
});
});
describe('on dispose', () => {
Expand Down Expand Up @@ -202,10 +202,10 @@ describe('GCPubSubClient', () => {
});
it('should publish packet', async () => {
await client['dispatchEvent'](msg);
expect(topicMock.publishJSON.called).to.be.true;
expect(topicMock.publishMessage.called).to.be.true;
});
it('should throw error', async () => {
topicMock.publishJSON.callsFake((a: any, b: any, c: any, d: any) =>
topicMock.publishMessage.callsFake((a: any, b: any, c: any, d: any) =>
d(new Error()),
);
client['dispatchEvent'](msg).catch((err) =>
Expand Down
7 changes: 4 additions & 3 deletions lib/gc-pubsub.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class GCPubSubClient extends ClientProxy {
});

if (this.topic) {
await this.topic.publishJSON(serializedPacket);
await this.topic.publishMessage({ json: serializedPacket });
}
}

Expand All @@ -141,8 +141,9 @@ export class GCPubSubClient extends ClientProxy {

if (this.topic) {
this.topic
.publishJSON(serializedPacket, {
replyTo: this.replyTopicName,
.publishMessage({
json: serializedPacket,
attributes: { replyTo: this.replyTopicName },
})
.catch((err) => callback({ err }));
} else {
Expand Down
16 changes: 10 additions & 6 deletions lib/gc-pubsub.server.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('GCPubSubServer', () => {
topicMock = {
create: sandbox.stub().resolves(),
flush: sandbox.stub().callsFake((callback) => callback()),
publishJSON: sandbox.stub().resolves(),
publishMessage: sandbox.stub().resolves(),
subscription: sandbox.stub().returns(subscriptionMock),
};

Expand Down Expand Up @@ -106,10 +106,12 @@ describe('GCPubSubServer', () => {
data: Buffer.from(JSON.stringify(msg)),
});
expect(
topicMock.publishJSON.calledWith({
id: msg.id,
status: 'error',
err: NO_MESSAGE_HANDLER,
topicMock.publishMessage.calledWith({
json: {
id: msg.id,
status: 'error',
err: NO_MESSAGE_HANDLER,
},
}),
).to.be.true;
});
Expand Down Expand Up @@ -146,7 +148,9 @@ describe('GCPubSubServer', () => {

await server.sendMessage(message, replyTo, correlationId);
expect(
topicMock.publishJSON.calledWith({ ...message, id: correlationId }),
topicMock.publishMessage.calledWith({
json: { ...message, id: correlationId },
}),
).to.be.true;
});
});
Expand Down
2 changes: 1 addition & 1 deletion lib/gc-pubsub.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export class GCPubSubServer extends Server implements CustomTransportStrategy {

await this.client
.topic(replyTo, this.publisherConfig)
.publishJSON(outgoingResponse);
.publishMessage({ json: outgoingResponse });
}

public async createIfNotExists(create: () => Promise<any>) {
Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
"devDependencies": {
"@commitlint/cli": "11.0.0",
"@commitlint/config-angular": "11.0.0",
"@google-cloud/pubsub": "2.19.0",
"@nestjs/common": "8.0.6",
"@nestjs/core": "8.0.6",
"@nestjs/microservices": "8.0.6",
"@nestjs/platform-express": "8.0.6",
"@nestjs/testing": "8.0.6",
"@google-cloud/pubsub": "3.2.0",
"@nestjs/common": "^9.0.0",
"@nestjs/core": "^9.0.0",
"@nestjs/microservices": "^9.0.0",
"@nestjs/platform-express": "^9.0.0",
"@nestjs/testing": "^9.0.0",
"@types/chai": "^4.2.21",
"@types/jest": "27.0.1",
"@types/node": "12.12.6",
Expand All @@ -64,10 +64,10 @@
"typescript": "4.4.3"
},
"peerDependencies": {
"@google-cloud/pubsub": "^2.0.0",
"@nestjs/common": "^8.0.0",
"@nestjs/core": "^8.0.0",
"@nestjs/microservices": "^8.0.0",
"@google-cloud/pubsub": "^3.0.0",
"@nestjs/common": "^9.0.0",
"@nestjs/core": "^9.0.0",
"@nestjs/microservices": "^9.0.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.0.0"
},
Expand Down
Loading

0 comments on commit 47b1833

Please sign in to comment.