Skip to content

kbrashears5/typescript-aws-helpers

Repository files navigation

typescript-aws-helpers

Collection of different AWS service helpers

CI/CD codecov NPM Version Downloads

Associated Helpers

Helper CI/CD Code Coverage Version Downloads
APIGatewayHelper CI/CD codecov NPM Version Downloads
CloudWatchHelper CI/CD codecov NPM Version Downloads
DynamoHelper CI/CD codecov NPM Version Downloads
KMSHelper CI/CD codecov NPM Version Downloads
LambdaHelper CI/CD codecov NPM Version Downloads
S3Helper CI/CD codecov NPM Version Downloads
SESHelper CI/CD codecov NPM Version Downloads
SNSHelper CI/CD codecov NPM Version Downloads
SQSHelper CI/CD codecov NPM Version Downloads
SSMHelper CI/CD codecov NPM Version Downloads
STSHelper CI/CD codecov NPM Version Downloads

Install

npm install typescript-aws-helpers@latest

Lambda Handlers

Example of a handler for a lambda:

Execute:

const handler = new Handler(LogLevel.Information);

export async function lambdaHandler(
  event: S3Event,
  context: Context,
  callback: Callback,
) {
  return (
    (await handler.Execute) <
    S3Event >
    (event,
    context,
    callback,
    async () => {
      this.Logger.Information('Executed');
    })
  );
}

Orchestrators

Examples of how to use orchestrators:

Orchestrate:

const handler = new Handler(LogLevel.Information);

const response =
  (await handler.Orchestrate) <
  string >
  (async () => {
    // do stuff
    this.Logger.Information(`Stuff was done`);
    return `Done`;
  });

OrchestrateSQS:

const handler = new Handler(LogLevel.Information);
const sqsEvent: SQSEvent = {
  Records: [{ body: 'body', receiptHandle: 'receipt-handle' }],
};

const response = await handler.OrchestrateSQS(
  sqsEvent.Records,
  'queue-url',
  async () => {
    // do stuff
    this.Logger.Information(`Stuff was done`);
  },
);

Helpers

See the appropriate helper repo for documentation on how to use them from the links in Associated Helpers

Development

Clone the latest and run

npm run prep

to install packages and prep the git hooks