Skip to content

Commit 4bddf86

Browse files
committed
feat: bump nestjs to 10
1 parent 1a9a5d9 commit 4bddf86

14 files changed

+13207
-7028
lines changed

.circleci/config.yml

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,37 @@
1-
version: 2
1+
version: 2.1
22

3-
aliases:
4-
- &restore-cache
5-
restore_cache:
6-
key: dependency-cache-{{ checksum "package.json" }}
7-
- &install-deps
8-
run:
9-
name: Install dependencies
10-
command: yarn install --frozen-lockfile
11-
- &build-packages
12-
run:
13-
name: Build
14-
command: yarn build
3+
orbs:
4+
node: circleci/[email protected]
155

166
jobs:
177
build:
188
working_directory: ~/nestjs-google-pubsub-microservice
19-
docker:
20-
- image: circleci/node:12
9+
executor: node/default
2110
steps:
2211
- checkout
2312
- run:
2413
name: Update NPM version
2514
command: 'sudo npm install -g npm@latest'
26-
- *restore-cache
27-
- *install-deps
28-
- save_cache:
29-
key: dependency-cache-{{ checksum "package.json" }}
30-
paths:
31-
- ./node_modules
32-
- *build-packages
15+
- node/install-packages
16+
- run:
17+
name: Build
18+
command: npm run build
3319
- run:
3420
name: Unit tests
35-
command: yarn test
21+
command: npm run test
22+
- persist_to_workspace:
23+
root: .
24+
paths:
25+
- .
3626

3727
integration_tests:
3828
working_directory: ~/nestjs-google-pubsub-microservice
3929
machine: true
4030
environment:
4131
PUBSUB_EMULATOR_HOST: localhost:8681
4232
steps:
43-
- checkout
33+
- attach_workspace:
34+
at: .
4435
- run:
4536
name: Prepare nvm
4637
command: |
@@ -49,20 +40,15 @@ jobs:
4940
- run:
5041
name: Upgrade Node.js
5142
command: |
52-
nvm install v12
43+
nvm install v18
5344
node -v
54-
nvm alias default v12
55-
- run:
56-
name: Install Yarn
57-
command: npm install yarn -g
45+
nvm alias default v18
5846
- run:
5947
name: Install Docker Compose
6048
command: |
6149
curl -L https://github.com/docker/compose/releases/download/1.19.0/docker-compose-`uname -s`-`uname -m` > ~/docker-compose
6250
chmod +x ~/docker-compose
6351
sudo mv ~/docker-compose /usr/local/bin/docker-compose
64-
- *restore-cache
65-
- *install-deps
6652
- run:
6753
name: Prepare
6854
command: |
@@ -73,10 +59,9 @@ jobs:
7359
command: docker ps
7460
- run:
7561
name: e2e tests
76-
command: yarn test:e2e
62+
command: npm run test:e2e
7763

7864
workflows:
79-
version: 2
8065
build-and-test:
8166
jobs:
8267
- build

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module.exports = {
22
parser: '@typescript-eslint/parser',
33
parserOptions: {
44
project: 'tsconfig.json',
5+
tsconfigRootDir: __dirname,
56
sourceType: 'module',
67
},
78
plugins: ['@typescript-eslint/eslint-plugin'],

docker-compose.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
version: "3"
1+
version: '3.3'
2+
23
services:
34
pubsub:
4-
image: messagebird/gcloud-pubsub-emulator:latest
5+
image: gcr.io/google.com/cloudsdktool/cloud-sdk:416.0.0-emulators
6+
entrypoint: gcloud
7+
command: ["beta", "emulators", "pubsub", "start", "--host-port=0.0.0.0:8681"]
58
ports:
69
- '8681:8681'
710
restart: always

lib/gc-pubsub.client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import {
44
PubSub,
55
Subscription,
66
Topic,
7+
PublishOptions,
8+
SubscriberOptions,
79
} from '@google-cloud/pubsub';
8-
import { PublishOptions } from '@google-cloud/pubsub/build/src/publisher';
9-
import { SubscriberOptions } from '@google-cloud/pubsub/build/src/subscriber';
1010
import { Logger } from '@nestjs/common';
1111
import {
1212
ClientProxy,

lib/gc-pubsub.context.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
import { Message } from '@google-cloud/pubsub';
22
import { BaseRpcContext } from '@nestjs/microservices/ctx-host/base-rpc.context';
33

4-
type GCPubSubContextArgs = [Message, string];
4+
type GCPubSubContextArgs<P> = [Message, P];
55

6-
export class GCPubSubContext extends BaseRpcContext<GCPubSubContextArgs> {
7-
constructor(args: GCPubSubContextArgs) {
6+
export class GCPubSubContext<P = string> extends BaseRpcContext<
7+
GCPubSubContextArgs<P>
8+
> {
9+
constructor(args: GCPubSubContextArgs<P>) {
810
super(args);
911
}
1012

1113
/**
1214
* Returns the original message (with properties, fields, and content).
1315
*/
14-
getMessage() {
16+
getMessage(): Message {
1517
return this.args[0];
1618
}
1719

1820
/**
1921
* Returns the name of the pattern.
2022
*/
21-
getPattern() {
23+
getPattern(): P {
2224
return this.args[1];
2325
}
2426
}

lib/gc-pubsub.interface.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { ClientConfig } from '@google-cloud/pubsub';
1+
import {
2+
ClientConfig,
3+
PublishOptions,
4+
SubscriberOptions,
5+
} from '@google-cloud/pubsub';
26
import { Deserializer, Serializer } from '@nestjs/microservices';
3-
import { PublishOptions } from '@google-cloud/pubsub/build/src/publisher';
4-
import { SubscriberOptions } from '@google-cloud/pubsub/build/src/subscriber';
57

68
export interface GCPubSubOptions {
79
client?: ClientConfig;

lib/gc-pubsub.server.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,7 @@ describe('GCPubSubServer', () => {
219219
const correlationId = '0';
220220

221221
await server.sendMessage(message, replyTo, correlationId);
222-
expect(Array.from(server['replyTopics'].values())).to.deep.eq([
223-
'my-keytest',
224-
]);
222+
expect(Array.from(server['replyTopics'].values())).to.deep.eq(['test']);
225223
});
226224
});
227225
});

lib/gc-pubsub.server.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {
22
ClientConfig,
33
Message,
4+
PublishOptions,
45
PubSub,
6+
SubscriberOptions,
57
Subscription,
68
} from '@google-cloud/pubsub';
7-
import { PublishOptions } from '@google-cloud/pubsub/build/src/publisher';
8-
import { SubscriberOptions } from '@google-cloud/pubsub/build/src/subscriber';
99
import { Observable } from 'rxjs';
1010
import {
1111
CustomTransportStrategy,
@@ -210,8 +210,6 @@ export class GCPubSubServer extends Server implements CustomTransportStrategy {
210210
message as unknown as OutgoingResponse,
211211
);
212212

213-
replyTo = `${this.scopedEnvKey}${replyTo}`;
214-
215213
this.replyTopics.add(replyTo);
216214

217215
await this.client

0 commit comments

Comments
 (0)