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

feat(eventBridge): adding in pocket event bridge package #240

Open
wants to merge 3 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,515 changes: 1,219 additions & 296 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions servers/collection-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
"@apollo/server-plugin-response-cache": "4.1.3",
"@apollo/server": "4.11.0",
"@apollo/subgraph": "2.9.0",
"@aws-sdk/client-eventbridge": "3.529.1",
"@aws-sdk/client-s3": "3.529.1",
"@aws-sdk/lib-storage": "3.529.1",
"@pocket-tools/apollo-utils": "3.5.0",
"@pocket-tools/feature-flags-client": "1.0.0",
"@pocket-tools/sentry": "1.0.0",
"@pocket-tools/tracing": "1.8.9",
"@pocket-tools/ts-logger": "^1.9.4",
"@pocket-tools/ts-logger": "1.9.6",
"@pocket-tools/event-bridge": "1.7.1",
"@prisma/client": "5.22.0",
"@sentry/node": "8.37.1",
"content-common": "workspace:*",
Expand Down
12 changes: 9 additions & 3 deletions servers/collection-api/src/aws/eventBridgeClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { EventBridgeClient } from '@aws-sdk/client-eventbridge';
import { PocketEventBridgeClient } from '@pocket-tools/event-bridge';
import config from '../config';

export const eventBridgeClient = new EventBridgeClient({
region: config.aws.region,
export const eventBridgeClient = new PocketEventBridgeClient({
eventBus: {
name: config.aws.eventBus.name,
},
aws: {
region: config.aws.region,
endpoint: config.aws.eventBus.endpoint,
},
});
1 change: 1 addition & 0 deletions servers/collection-api/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default {
},
region: process.env.AWS_DEFAULT_REGION || 'us-east-1',
eventBus: {
endpoint: localEndpoint,
name:
process.env.EVENT_BUS_NAME || 'PocketEventBridge-Dev-Shared-Event-Bus',
eventBridge: { source: 'collection-events' },
Expand Down
8 changes: 4 additions & 4 deletions servers/collection-api/src/database/mutations/Collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { checkCollectionLabelLimit } from '../utils';
import { NotFoundError } from '@pocket-tools/apollo-utils';
import { AdminAPIUser } from '../../admin/context';
import { sendEventBridgeEvent } from '../../events/events';
import { EventBridgeEventType } from '../../events/types';
import { PocketEventType } from '@pocket-tools/event-bridge';

/**
* @param db
Expand Down Expand Up @@ -129,7 +129,7 @@ export async function createCollection(

await sendEventBridgeEvent(
db,
EventBridgeEventType.COLLECTION_CREATED,
PocketEventType.COLLECTION_CREATED,
collection,
);

Expand Down Expand Up @@ -312,7 +312,7 @@ export async function updateCollection(
// send event bridge event for collection_updated event type
await sendEventBridgeEvent(
db,
EventBridgeEventType.COLLECTION_UPDATED,
PocketEventType.COLLECTION_UPDATED,
collection,
);

Expand Down Expand Up @@ -357,7 +357,7 @@ export async function updateCollectionImageUrl(
// send event bridge event for collection_updated event type
await sendEventBridgeEvent(
db,
EventBridgeEventType.COLLECTION_UPDATED,
PocketEventType.COLLECTION_UPDATED,
collection,
);
return collection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
sendEventBridgeEvent,
sendEventBridgeEventUpdateFromInternalCollectionId,
} from '../../events/events';
import { EventBridgeEventType } from '../../events/types';
import { PocketEventType } from '@pocket-tools/event-bridge';

/**
* @param db
Expand Down Expand Up @@ -56,7 +56,7 @@ export async function createCollectionStory(
});
await sendEventBridgeEvent(
db,
EventBridgeEventType.COLLECTION_UPDATED,
PocketEventType.COLLECTION_UPDATED,
collection,
);
return story;
Expand Down
Loading