npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cognito-custom-email

v1.1.6

Published

Lambda responsible for triggering personalized emails by platform. This project uses serverless.

Downloads

2

Readme

Cognito Custom Message Lambda

Lambda responsible for triggering personalized emails by platform. This project uses serverless.

Content

Technologies

Configuration

All configuration values should defined using environment variables. as we are using server-less framework, to automatically define environment variables on deploy, you should put all values in the file .env.yml and the server-less will define thats values on AWS Lambda environment when you run the deploy command.

Secrets

Secrets are injected into your functions using environment variables. By defining variables in the provider section of the serverless.yml you add them to the environment of the deployed function. From there, you can reference them in your functions as well.

So you would add something like:

provider:
  environment:
    A_VARIABLE: ${env:A_VARIABLE}

to your serverless.yml, and then you can add A_VARIABLE to your GitLab Ci variables and it will get picked up and deployed with your function.

For local development, we suggest installing something like dotenv to manage environment variables.

Setting Up AWS

  1. Create AWS credentials including the following inline IAM policy:

    {
        "Statement": [
            {
                "Action": [
                    "apigateway:*",
                    "cloudformation:CancelUpdateStack",
                    "cloudformation:ContinueUpdateRollback",
                    "cloudformation:CreateChangeSet",
                    "cloudformation:CreateStack",
                    "cloudformation:CreateUploadBucket",
                    "cloudformation:DeleteStack",
                    "cloudformation:Describe*",
                    "cloudformation:EstimateTemplateCost",
                    "cloudformation:ExecuteChangeSet",
                    "cloudformation:Get*",
                    "cloudformation:List*",
                    "cloudformation:PreviewStackUpdate",
                    "cloudformation:UpdateStack",
                    "cloudformation:UpdateTerminationProtection",
                    "cloudformation:ValidateTemplate",
                    "lambda:*",
                    "logs:CreateLogGroup",
                    "logs:DeleteLogGroup",
                    "logs:DescribeLogGroups",
                    "logs:DescribeLogStreams",
                    "logs:FilterLogEvents",
                    "logs:GetLogEvents",
                    "s3:CreateBucket",
                    "s3:DeleteBucket",
                    "s3:DeleteBucketPolicy",
                    "s3:DeleteObject",
                    "s3:DeleteObjectVersion",
                    "s3:GetObject",
                    "s3:GetObjectVersion",
                    "s3:ListAllMyBuckets",
                    "s3:ListBucket",
                    "s3:PutBucketNotification",
                    "s3:PutBucketPolicy",
                    "s3:PutBucketTagging",
                    "s3:PutBucketWebsite",
                    "s3:PutEncryptionConfiguration",
                    "s3:PutObject"
                ],
                "Effect": "Allow",
                "Resource": "*"
            }
        ],
        "Version": "2022-02-18"
    }
  2. Set the AWS_SHARED_CREDENTIALS_FILE variable with type file in the GitLab CI/CD settings. Settings > CI/CD > Variables.

  3. Inside it should be:

	aws_access_key_id = <access_key_id>
	aws_secret_access_key = <secret_access_key>
	[staging]
	aws_access_key_id = <access_key_id>
	aws_secret_access_key = <secret_access_key>
	[production]
	aws_access_key_id = <access_key_id>
	aws_secret_access_key = <secret_access_key>

NODE_ENV

Define the current environment. This value will be used to define what email template should be used for each message.

  • Optional
  • String
  • Default: development

COGNITO_ESANAR_SOCIAL_APP_ID

The id used to send an email when the user first login with social network.

  • Required
  • String

Templates

This folder stores the same templates in tree directories

development

Stores templates used in development environment

staging

Store templates used in staging environment

production

Store templates used in production environment

Files to be Created

sonar-project.properties

  • Sets Sonar properties for code inspection

Launch local

  1. $ git clone [email protected]:sanardigital/identidade/cognito-lambdas/custom-message.git.
  2. $ cd <folder-source-code>
  3. $ npm install
  4. Set up your aws credentials on your OS. You may need to install aws-cli first. It will be necessary in case of manually deploying the project.
  5. $ clear && npm run dev Execute local. This is for debugging and tests purpose.
  6. You did it, you are great!! Enjoy! :rocket:

Scripts

Running

  • $ npm run dev

Testing

  • $ npm run test

  • $ npm run test:debug

Linting

  • $ npm run lint

  • $ npm run lint:fix

Deploying - Not recommended

  • $ npm run deploy:staging

  • $ npm run deploy:production

Project dependencies

Tips

  • Without AWS credentials you will not be able to deploy the project
  • Before each git commit the lint will be run.
  • Before each git push the unit tests will be run.
  • This project uses clean architecture, so it'll be easy to understand folder structure and project organization if you have previous knowledge about this architecture.

Contribuitors

Time Identidade [email protected] \

License

(c) Not a free software