Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps-dev): bump supertest from 6.3.4 to 7.0.0 #175

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ RUN apk add --no-cache \
npm i [email protected] [email protected] -g && \
rm -rf /var/lib/apt/lists/* && \
gcloud components install pubsub-emulator --quiet && \
gcloud components install beta --quiet && \
gcloud components update --quiet

COPY ./package.json .
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
"lint-staged": "^15.2.2",
"npm-watch": "^0.11.0",
"prettier": "^3.2.5",
"supertest": "^6.3.4",
"supertest": "^7.0.0",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
Expand Down
27 changes: 12 additions & 15 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/infra/events/ids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ export const EVENT_ID = {
DELETE_MEMBER: Symbol.for('delete_member'),
DELETE_CONDOMINIUM: Symbol.for('delete_condominium'),
},
TRACE: {
INTERNALS: 'Internal event',
PUBSUB: 'Pubsub event',
},
};
31 changes: 25 additions & 6 deletions src/infra/events/pubsub/google/publishers/deleteCondominium.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable } from '@nestjs/common';
import { Inject, Injectable } from '@nestjs/common';
import { GooglePubSubService } from '../pubsub.service';
import { OnEvent } from '@nestjs/event-emitter';
import { EVENT_ID } from '@infra/events/ids';
Expand All @@ -7,23 +7,42 @@ import {
IDeleteCondominiumProps,
} from '@app/publishers/deleteCondominium';
import { CondominiumMapper } from '@app/mapper/condominium';
import { TRACE_ID, TraceHandler } from '@infra/configs/tracing';

@Injectable()
export class DeleteCondominiumGooglePublisher
implements DeleteCondominiumPublisher
{
constructor(private readonly pubSubService: GooglePubSubService) {}
constructor(
private readonly pubSubService: GooglePubSubService,
@Inject(TRACE_ID)
private readonly trace: TraceHandler,
) {}

private readonly topicName = 'delete_condominium';

@OnEvent(EVENT_ID.PUBSUB.DELETE_CONDOMINIUM, { async: true })
async publish(input: IDeleteCondominiumProps): Promise<void> {
const tracer = this.trace.getTracer(EVENT_ID.TRACE.PUBSUB);
const span = tracer.startSpan(`topic: ${this.topicName}`);

const topic = this.pubSubService.topic(this.topicName);
if (process.env.NODE_ENV !== 'production' || !topic.exists()) return;
const topicExist = await topic.exists();
if (process.env.NODE_ENV !== 'production' || !topicExist[0]) {
span.setAttribute('published', 'false');
return span.end();
}

const condominium = CondominiumMapper.toObject(input.condominium);
await topic.publishMessage({
json: { condominium, deletedAt: input.deletedAt },
});
const data = Buffer.from(
JSON.stringify({
condominium,
deletedAt: input.deletedAt,
}),
);
await topic.publishMessage({ data });

span.setAttribute('published', 'true');
span.end();
}
}
30 changes: 23 additions & 7 deletions src/infra/events/pubsub/google/publishers/deleteMember.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,44 @@
import { Injectable } from '@nestjs/common';
import { Inject, Injectable } from '@nestjs/common';
import { GooglePubSubService } from '../pubsub.service';
import { OnEvent } from '@nestjs/event-emitter';
import { EVENT_ID } from '@infra/events/ids';
import {
DeleteMemberPublisher,
IDeleteMemberProps,
} from '@app/publishers/deleteMember';
import { TRACE_ID, TraceHandler } from '@infra/configs/tracing';

@Injectable()
export class DeleteMemberGooglePublisher implements DeleteMemberPublisher {
constructor(private readonly pubSubService: GooglePubSubService) {}
constructor(
private readonly pubSubService: GooglePubSubService,
@Inject(TRACE_ID)
private readonly trace: TraceHandler,
) {}

private readonly topicName = 'delete_member';

@OnEvent(EVENT_ID.PUBSUB.DELETE_MEMBER, { async: true })
async publish(input: IDeleteMemberProps): Promise<void> {
const tracer = this.trace.getTracer(EVENT_ID.TRACE.PUBSUB);
const span = tracer.startSpan(`topic: ${this.topicName}`);

const topic = this.pubSubService.topic(this.topicName);
if (process.env.NODE_ENV !== 'production' || !topic.exists()) return;
const topicExists = await topic.exists();
if (process.env.NODE_ENV !== 'production' || !topicExists[0]) {
span.setAttribute('published', 'false');
return span.end();
}

await topic.publishMessage({
json: {
const data = Buffer.from(
JSON.stringify({
uniqueRegistry: input.uniqueRegistry,
deletedAt: input.deletedAt,
},
});
}),
);
await topic.publishMessage({ data });

span.setAttribute('published', 'true');
span.end();
}
}
30 changes: 23 additions & 7 deletions src/infra/events/pubsub/google/publishers/deleteUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,35 @@ import {
DeleteUserPublisher,
IDeleteUserProps,
} from '@app/publishers/deleteUser';
import { Injectable } from '@nestjs/common';
import { Inject, Injectable } from '@nestjs/common';
import { GooglePubSubService } from '../pubsub.service';
import { UserMapper } from '@app/mapper/user';
import { OnEvent } from '@nestjs/event-emitter';
import { EVENT_ID } from '@infra/events/ids';
import { UniqueRegistryMapper } from '@app/mapper/uniqueRegistry';
import { TRACE_ID, TraceHandler } from '@infra/configs/tracing';

@Injectable()
export class DeleteUserGooglePublisher implements DeleteUserPublisher {
constructor(private readonly pubSubService: GooglePubSubService) {}
constructor(
private readonly pubSubService: GooglePubSubService,
@Inject(TRACE_ID)
private readonly trace: TraceHandler,
) {}

private readonly topicName = 'delete_user';

@OnEvent(EVENT_ID.PUBSUB.DELETE_USER, { async: true })
async publish(input: IDeleteUserProps): Promise<void> {
const tracer = this.trace.getTracer(EVENT_ID.TRACE.PUBSUB);
const span = tracer.startSpan(`topic: ${this.topicName}`);

const topic = this.pubSubService.topic(this.topicName);
if (process.env.NODE_ENV !== 'production' || !topic.exists()) return;
const topicExists = await topic.exists();
if (process.env.NODE_ENV !== 'production' || !topicExists[0]) {
span.setAttribute('published', 'false');
return span.end();
}

const user = UserMapper.toObject(input.user) as any;
delete user.password;
Expand All @@ -27,12 +39,16 @@ export class DeleteUserGooglePublisher implements DeleteUserPublisher {
input.uniqueRegistry,
);

await topic.publishMessage({
json: {
const data = Buffer.from(
JSON.stringify({
user,
uniqueRegistry,
deletedAt: input.deletedAt,
},
});
}),
);
await topic.publishMessage({ data });

span.setAttribute('published', 'true');
span.end();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { AdaptersModule } from '@app/adapters/adapter.module';
import { DeleteCondominiumPublisher } from '@app/publishers/deleteCondominium';
import { ConfigModule } from '@infra/configs/config.module';
import { PubSubModule } from '@infra/events/pubsub/pubsub.module';
import { TestingModule, Test } from '@nestjs/testing';
import { condominiumFactory } from '@tests/factories/condominium';
Expand All @@ -9,7 +11,7 @@ describe('Delete condominium google publisher test', () => {

beforeAll(async () => {
app = await Test.createTestingModule({
imports: [PubSubModule],
imports: [PubSubModule, ConfigModule, AdaptersModule],
}).compile();

sut = app.get(DeleteCondominiumPublisher);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { AdaptersModule } from '@app/adapters/adapter.module';
import { UniqueRegistryMapper } from '@app/mapper/uniqueRegistry';
import { DeleteMemberPublisher } from '@app/publishers/deleteMember';
import { ConfigModule } from '@infra/configs/config.module';
import { PubSubModule } from '@infra/events/pubsub/pubsub.module';
import { TestingModule, Test } from '@nestjs/testing';
import { uniqueRegistryFactory } from '@tests/factories/uniqueRegistry';
Expand All @@ -10,7 +12,7 @@ describe('Delete member google publisher test', () => {

beforeAll(async () => {
app = await Test.createTestingModule({
imports: [PubSubModule],
imports: [PubSubModule, ConfigModule, AdaptersModule],
}).compile();

sut = app.get(DeleteMemberPublisher);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ import { PubSubModule } from '@infra/events/pubsub/pubsub.module';
import { TestingModule, Test } from '@nestjs/testing';
import { uniqueRegistryFactory } from '@tests/factories/uniqueRegistry';
import { userFactory } from '@tests/factories/user';
import { ConfigModule } from '@infra/configs/config.module';
import { AdaptersModule } from '@app/adapters/adapter.module';

describe('Delete user google publisher test', () => {
let app: TestingModule;
let sut: DeleteUserPublisher;

beforeAll(async () => {
app = await Test.createTestingModule({
imports: [PubSubModule],
imports: [PubSubModule, ConfigModule, AdaptersModule],
}).compile();

sut = app.get(DeleteUserPublisher);
Expand Down
Loading