generated from dvsa/dvsa-lambda-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cb2-10047): add service for aws SNS (#93)
Co-authored-by: owen <[email protected]>
- Loading branch information
1 parent
a3dc937
commit 3bba0de
Showing
12 changed files
with
688 additions
and
187 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,5 +1,9 @@ | ||
import { TechRecordType } from '@dvsa/cvs-type-definitions/types/v3/tech-record/tech-record-verb'; | ||
|
||
export type UpdateVrmRequestBody = { | ||
newVrm: string | ||
isCherishedTransfer: boolean, | ||
thirdMark?: string | ||
}; | ||
|
||
export type SNSMessageBody = TechRecordType<'get'> & { userEmail?: string }; |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { SNSClient, PublishCommand } from '@aws-sdk/client-sns'; | ||
import logger from '../util/logger'; | ||
|
||
const snsClient = new SNSClient({ region: process.env.DYNAMO_AWS_REGION }); | ||
|
||
export const publish = async (message: string, topicArn: string) => { | ||
logger.info('Sending SNS notification'); | ||
|
||
if (process.env.AWS_SAM_LOCAL) { | ||
return '123'; | ||
} | ||
const input = { | ||
TopicArn: topicArn, | ||
Message: message, | ||
}; | ||
|
||
const command = new PublishCommand(input); | ||
try { | ||
const response = await snsClient.send(command); | ||
logger.debug(response); | ||
return undefined; | ||
} catch (err: unknown) { | ||
logger.error(err); | ||
throw new Error(err as string); | ||
} | ||
}; |
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
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