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

serverless-with-cloudfront

v0.0.9

Published

CloudFront distribution in front of your http api gateway

Downloads

299

Readme

serverless-with-cloudfront

CircleCI serverless npm version MIT licensed npm downloads

A try to extend the project: https://github.com/Droplr/serverless-api-cloudfront

Automatically properly configured AWS CloudFront distribution that routes traffic to follow resource.

Automatically config custom domain and create Route 53 records

Installation

$ npm install --save-dev serverless-with-cloudfront

OR

$ yarn add -D serverless-with-cloudfront

Usage

Samples

A HTTP api gateway sample

Add to plugins section

plugins:
  - serverless-with-cloudfront

Add to custom section

custom:
  withCloudFront:
    type: http # for HTTP Api Gateway
  ...
# The `service` block is the name of the service
service: sample

frameworkVersion: '3'

plugins:
  - serverless-with-cloudfront

# The `provider` block defines where your service will be deployed
provider:
  name: aws
  runtime: nodejs12.x
  region: ap-northeast-1

custom:
  withCloudFront:
    type: http # for HTTP Api Gateway
    # hostedZoneId: 11223344
    # domain: my-custom-domain.com
    # certificate: arn:aws:acm:us-east-1:000000000000:certificate/00000000-1111-2222-3333-444444444444
    headers:
      - Accept
      - Accept-Encoding
      - Accept-Language
      - Authorization
    # cookies: 'all'
    # querystring: 'all'
    # waf: 00000000-0000-0000-0000-000000000000
    # compress: true
    # minimumProtocolVersion: 'protocol version'
    # priceClass: 'PriceClass_All'
    # logging:
    #   bucket: my-bucket.s3.amazonaws.com
    #   prefix: my-prefix

# The `functions` block defines what code to deploy
functions:
  helloWorld:
    handler: handler.helloWorld
    # The `events` block defines how to trigger the handler.helloWorld code
    events:
      - httpApi: '*'

A REST api gateway sample

A Lambda Url sample

lambda must be set to the same name of target function

function must set url property

custom:
  withCloudFront:
    type: lambda
    lambda: helloWorld
  ...

functions:
  helloWorld:
    url: true
    ...

Configuration

| field | must | default | - | | ---------------------- | ---- | ------------------ | --------------------------------------------------------------------------------- | | type | * | - | http | | | | | rest | | | | | lambda | | lambda | △ | | If the type is lambda, this field must be set to the target function name | | hostedZoneId | | | The Route 53 Hosted zone ID | | domain | | | The custom domain name | | certificate | | | The certificate of custom domain name | | headers | | [] | The headers that include in the cache key | | cookies | | all | The cookies that include in the cache key ( all, none or a whitelist) | | queryString | | all | The query strings that include in the cache key all, none or a whitelist) | | waf | | | The id of WAF | | compress | | false | The auto compress option: true | false | | minimumProtocolVersion | | TLSv1 | TLSv1 | TLSv1_2016 | TLSv1.1_2016 | TLSv1.2_2018 | SSLv3 | | priceClass | | PriceClass_All | PriceClass_All | PriceClass_100 | PriceClass_200 | | logging | | | Bucket and prefix settings for saving access logs |

Notes

  • If domain is set, certificate also needs to be set
domain: my-custom-domain.com
certificate: arn:aws:acm:us-east-1:000000000000:certificate/00000000-1111-2222-3333-444444444444
  • If hostedZoneId is set, domain (and certificate) also needs to be set
hostedZoneId: 11223344
domain: my-custom-domain.com
certificate: arn:aws:acm:us-east-1:000000000000:certificate/00000000-1111-2222-3333-444444444444
headers:
  - Accept
  - Accept-Encoding
  - Accept-Language
  - Authorization

IAM Policy

In order to make this plugin work as expected a few additional IAM Policies might be needed on your AWS profile.

  • cloudfront:...
  • route53:...

You can read more about IAM profiles and policies in the Serverless documentation.

License

MIT