forked from kibertoad/message-queue-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SnsPermissionPublisher.ts
42 lines (38 loc) · 1.37 KB
/
SnsPermissionPublisher.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { AbstractSnsPublisher } from '../../lib/sns/AbstractSnsPublisher'
import type { SNSDependencies, SNSOptions } from '../../lib/sns/AbstractSnsService'
import type {
PERMISSIONS_ADD_MESSAGE_TYPE,
PERMISSIONS_REMOVE_MESSAGE_TYPE,
} from '../consumers/userConsumerSchemas'
import {
PERMISSIONS_ADD_MESSAGE_SCHEMA,
PERMISSIONS_REMOVE_MESSAGE_SCHEMA,
} from '../consumers/userConsumerSchemas'
type SupportedTypes = PERMISSIONS_ADD_MESSAGE_TYPE | PERMISSIONS_REMOVE_MESSAGE_TYPE
export class SnsPermissionPublisher extends AbstractSnsPublisher<SupportedTypes> {
public static readonly TOPIC_NAME = 'user_permissions_multi'
constructor(
dependencies: SNSDependencies,
options?: Pick<SNSOptions, 'creationConfig' | 'locatorConfig' | 'payloadStoreConfig'>,
) {
super(dependencies, {
...(options?.locatorConfig
? { locatorConfig: options?.locatorConfig }
: {
creationConfig: options?.creationConfig ?? {
topic: { Name: SnsPermissionPublisher.TOPIC_NAME },
},
}),
deletionConfig: {
deleteIfExists: false,
},
payloadStoreConfig: options?.payloadStoreConfig,
messageSchemas: [PERMISSIONS_ADD_MESSAGE_SCHEMA, PERMISSIONS_REMOVE_MESSAGE_SCHEMA],
handlerSpy: true,
messageTypeField: 'messageType',
})
}
get topicArnProp(): string {
return this.topicArn
}
}