0.2.2 • Published 9 months ago

@gotamedia/aws v0.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

Gota Media AWS

A light-weight wrapper around some of AWS JS-SDK v3 AWS.

Usage

npm install @gotamedia/aws
import { invoke } from "@gotamedia/aws/services/Lambda"

const handler = () => {
    invoke(...)
}

Services

Available services:

  • Lambda
  • S3
  • SNS
  • SQS
  • SSM
  • Xray

Utils

Available utils:

  • silenceXrayContextErrors

NOTE: All services exports thier own client: import { client as LambdaClient } from "@gotamedia/aws/services/Lambda"

Lambda

A light-weight wrapper arround @aws-sdk/clients-lambda wrapped with Xray traces

Available methods:

invoke()
paramtypedefaultrequireddescription
firstInvokeCommandInputundefinedxAWS Lambda InvokeCommandInput params

Example:

import { invoke } from "@gotamedia/aws/services/Lambda"
import type { InvokeCommandInput } from "@aws-sdk/client-lambda"

const handler = async () => {
    const invokeCommandInput: InvokeCommandInput = {
        FunctionName: "my-awesome-function",
        InvocationType: "Event"
    }

    const response = await invoke(invokeCommandInput)
}

S3

A light-weight wrapper arround @aws-sdk/clients-s3 wrapped with Xray traces

Available methods:

getObject()
paramtypedefaultrequireddescription
firstGetObjectCommandInputundefinedxAWS S3 GetObjectCommandInput params

Example:

import { getObject } from "@gotamedia/aws/services/S3"
import type { GetObjectCommandInput } from "@aws-sdk/client-s3"

const handler = async () => {
    const getObjectCommandInput: GetObjectCommandInput = {
        Bucket: "my-awesome-bucket",
        Key: "my-awesome-key"
    }

    const response = await getObject(getObjectCommandInput)
}

S3

A light-weight wrapper arround @aws-sdk/clients-s3 wrapped with Xray traces

Available methods:

putObject()
paramtypedefaultrequireddescription
firstPutObjectCommandInputundefinedxAWS S3 PutObjectCommandInput params

Example:

import { putObject } from "@gotamedia/aws/services/S3"
import type { PutObjectCommandInput } from "@aws-sdk/client-s3"

const handler = async () => {
    const putObjectCommandInput: PutObjectCommandInput = {
        Bucket: "my-awesome-bucket",
        Key: "my-awesome-key",
        Body: JSON.stringify({
            id: "123-321",
            awesome: true,
            ContentType: "application/json"
        })
    }

    const response = await putObject(putObjectCommandInput)
}

S3

A light-weight wrapper arround @aws-sdk/clients-s3 wrapped with Xray traces

Available methods:

deleteObject()
paramtypedefaultrequireddescription
firstDeleteObjectCommandInputundefinedxAWS S3 DeleteObjectCommandInput params

Example:

import { deleteObject } from "@gotamedia/aws/services/S3"
import type { DeleteObjectCommandInput } from "@aws-sdk/client-s3"

const handler = async () => {
    const deleteObjectCommandInput: DeleteObjectCommandInput = {
        Bucket: "my-awesome-bucket",
        Key: "my-awesome-key"
    }

    const response = await deleteObject(deleteObjectCommandInput)
}

SNS

A light-weight wrapper arround @aws-sdk/clients-sns wrapped with Xray traces

Available methods:

publishMessage()
paramtypedefaultrequireddescription
firstPublishCommandInputundefinedxAWS SNS PublishCommandInput params

Example:

import { publishMessage } from "@gotamedia/aws/services/SNS"
import type { PublishCommandInput } from "@aws-sdk/client-sns"

const handler = async () => {
    const publishMessageCommandInput: PublishCommandInput = {
        TopicArn: "my-awesome-topic",
        Message: "Hello from @gotamedia/aws package!"
    }

    await publishMessage(publishMessageCommandInput)
}

SQS

A light-weight wrapper arround @aws-sdk/clients-sqs wrapped with Xray traces

Available methods:

sendMessage()
paramtypedefaultrequireddescription
firstSendMessageCommandInputundefinedxAWS SQS SendMessageCommandInput params

Example:

import { sendMessage } from "@gotamedia/aws/services/SQS"
import type { SendMessageCommandInput } from "@aws-sdk/client-sqs"

const handler = async () => {
    const sendMessageCommandInput: SendMessageCommandInput = {
        QueueUrl: "my-awesome-queue",
        MessageBody: "Hello from @gotamedia/aws package!"
    }

    await sendMessage(sendMessageCommandInput)
}
sendMessageBatch()
paramtypedefaultrequireddescription
firstSendMessageBatchCommandInputundefinedxAWS SQS SendMessageBatchCommandInput params

Example:

import { sendMessageBatch } from "@gotamedia/aws/services/SQS"
import type { SendMessageBatchCommandInput } from "@aws-sdk/client-sqs"

const handler = async () => {
    const sendMessageBatchCommandInput: SendMessageBatchCommandInput = {
        QueueUrl: "my-awesome-queue",
        Entries: [
            {
                Id: "123-321",
                MessageBody: "1: Hello from @gotamedia/aws package!"
            },
            {
                Id: "321-123",
                MessageBody: "2: Hello from @gotamedia/aws package!"
            }
        ]
    }

    await sendMessageBatch(sendMessageBatchCommandInput)
}

SSM

A light-weight wrapper arround @aws-sdk/clients-ssm wrapped with Xray traces

Available methods:

getParameter()
paramtypedefaultrequireddescription
firstGetParameterCommandInputundefinedxAWS SSM GetParameterCommandInput params

Example:

import { getParameter } from "@gotamedia/aws/services/SSM"
import type { GetParameterCommandInput } from "@aws-sdk/client-ssm"

const handler = async () => {
    const getParameterCommandInput: GetParameterCommandInput = {
        Name: "my-awesome-parameter"
    }

    const parameterValue = await getParameter(getParameterCommandInput)
}
putParameter()
paramtypedefaultrequireddescription
firstPutParameterCommandundefinedxAWS SSM PutParameterCommand params

Example:

import { putParameter } from "@gotamedia/aws/services/SSM"
import type { PutParameterCommand } from "@aws-sdk/client-ssm"

const handler = async () => {
    const putParameterCommandInput: PutParameterCommand = {
        Name: "my-awesome-parameter",
        Value: "my-awesome-value",
        Type: "String"
    }

    await putParameter(putParameterCommandInput)
}

Xray

A helper service to help you wrapping AWS-SDK V3 Clients with Xray

Available methods:

wrapClient()
paramtypedefaultrequireddescription
firstAWS ClientundefinedxAWS SDK V3 Client

Example:

import { DynamodbClient } from "@aws-sdk/clients-dynamodb"
import { wrapClient } from "@gotamedia/aws/services/Xray"

const Dynamodb = wrapClient(new DynamodbClient({ region: "eu-north-1" }))

const handler = async () => {
    // Use DynamoDB sdk commands...
}

Available utils:

silenceXrayContextErrors

A helper util to silence Xray "Missing AWS Lambda trace data for Xray @Object.contextMissingLogError"

Example:

import "@gotamedia/aws/utils/silenceXrayContextErrors"

const handler = async () => {
    ...
}

Contributing

Trunk based development

This project uses a trunk based development workflow.

NOTE: master is the trunk branch

Conventional commits

This project works with conventional commits.

Contribute

  • Pull latest from develop.
  • Branch out a new branch.
  • Commit and push your awesome code.
  • Open a pull request so we can approve your awesome code.

Publish

Any time you push to origin master branch, a pipeline will be automatically triggered and it will build the package for you. The pipeline will bump the version for you automatically and tag the package.

NOTE: NO MANUAL TAGGING

Then it will generate and update the CHANGELOG depends on your pushed commits.

License

MIT

0.2.1

9 months ago

0.2.2

9 months ago

0.2.0

11 months ago

0.1.2

11 months ago

0.1.1

11 months ago

0.1.0

11 months ago

0.0.8

11 months ago

0.0.7

11 months ago

0.0.6

11 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.0.1

11 months ago