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-dir-config-plugin

v0.1.5

Published

This plugin loads serverless.js configurations from set of directories as well as the main file.

Downloads

497

Readme

serverless-dir-config-plugin

This is a plugin makes it possible to keep your function and resource definitions in separate files in a directory structure instead of the serverless.yml

#Installation External Plugins are added on a per service basis and are not applied globally. Make sure you are in your Service's root directory, then install the corresponding Plugin with the help of NPM:

npm install --save serverless-dir-config-plugin

In your service create a directory structure like

mkdir serverless
mkdir serverless/functions
mkdir serverless/resources

The plugin will look in these directories for files ending in .yml to load in. You can nest them any way you want. They use the same structure of yaml as the way they are included in the serverless.yml. They also support all the variable resolution that the main file supports.

hello:
  handler: lib/handler.hello
  role: BasicLambdaRole
  events:
    - http:
        path: hello
        method: get
        integration: lambda-proxy

Keep in mind for the resources there are multiple resource types. I tend to create directories for different groupings (ima, dynamodb,etc)

Make sure you include the type first (Resources/Outputs etc):

Resources:
  BasicLambdaRole:
    Type: AWS::IAM::Role
    Properties:
      RoleName: ${self:service}-${self:provider.stage}-BasicLambdaRole
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Effect: Allow
            Principal:
              Service:
                - lambda.amazonaws.com
            Action: sts:AssumeRole
      Policies:
        - PolicyName: ${self:service}-${self:provider.stage}-BasicLambdaPolicy
          PolicyDocument:
            Version: '2012-10-17'
            Statement:
              - Effect: Allow
                Action:
                  - "logs:*"
                  - "cloudwatch:*"
                Resource: "*"

Configuration

You need to add it to the plugin section of the serverless.yml

plugins:
  - serverless-dir-config-plugin

Currently the only thing you can configure is if it shows what resources and functions are being loaded. If you don't want to see that - set quiet to true.


custom:
  dirconfig:
      quiet: false

Warnings

Serverless.js doesn't provide hooks to append to the config file. This plugin ends up making some assumptions to work.

  1. Currently the framework loads all the plugins before it does anything. This allows the plugin to look for the files and append them to the configuration before anything happens.

  2. After the configuration is loaded all the variables get resolved. The plugin monkeypatches this process so it can add in function names once the variables are all set.

This means that right now the way the plugin works is very fragile. If the Serverless.js changes the way they load things - this plugin will break. I am hoping that after confirming that this plugin is useful I will submit a PR that looks at giving plugins access to the hooks that I'm basically inventing.