-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: publish AssetBundleConverted event
- Loading branch information
Showing
6 changed files
with
37 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,32 @@ | ||
import { PublishCommand, SNSClient } from '@aws-sdk/client-sns' | ||
import { AppComponents, PublisherComponent } from '../types' | ||
|
||
export async function createSnsComponent({ | ||
config, | ||
}: Pick<AppComponents, 'config'>): Promise<PublisherComponent> { | ||
export async function createSnsComponent({ config }: Pick<AppComponents, 'config'>): Promise<PublisherComponent> { | ||
const snsArn = await config.requireString('AWS_SNS_ARN') | ||
const optionalEndpoint = await config.getString('AWS_SNS_ENDPOINT') | ||
|
||
const client = new SNSClient({ | ||
endpoint: optionalEndpoint ? optionalEndpoint : undefined, | ||
endpoint: optionalEndpoint ? optionalEndpoint : undefined | ||
}) | ||
|
||
async function publishMessage(event: any): Promise<void> { | ||
const command = new PublishCommand({ | ||
TopicArn: snsArn, | ||
Message: JSON.stringify(event), | ||
MessageAttributes: { | ||
type: { | ||
DataType: 'String', | ||
StringValue: event.type, | ||
}, | ||
subType: { | ||
DataType: 'String', | ||
StringValue: event.subType, | ||
}, | ||
async function publishMessage(event: any, attributes: { type: string; subType: string }): Promise<void> { | ||
const command = new PublishCommand({ | ||
TopicArn: snsArn, | ||
Message: JSON.stringify(event), | ||
MessageAttributes: { | ||
type: { | ||
DataType: 'String', | ||
StringValue: attributes.type | ||
}, | ||
}) | ||
subType: { | ||
DataType: 'String', | ||
StringValue: attributes.subType | ||
} | ||
} | ||
}) | ||
|
||
await client.send(command) | ||
await client.send(command) | ||
} | ||
|
||
return { publishMessage } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters