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

dromedary-serverless

v0.1.0

Published

- Deploy dromedary to AWS Lambda

Downloads

3

Readme

Overview

This project deploys dromedary in AWS Lambda with API Gateway as the interface to demonstrate serverless architecture. It also demonstrates the use of CodePipeline with Lambdas to continuously deliver changes made in the source code in a serverless manner.

Architecture Overview

The application is split into 2 separate parts for deployment:

  • API - deployed as a Lambda function using API Gateway for the front end.
  • Static Content - deployed into an S3 bucket with website hosting enabled.

Additionally, a config.json file is generated and deployed into the S3 bucket containing the endpoint to use for the API in API Gateway.

app-overview

Pipeline Overview

The pipeline consists of the following steps:

  • commit - a commit in GitHub triggers a new CodePipeline job. The source is downloaded from GitHub and then pushed into an S3 bucket as a zip file.
  • npm lambda - a lambda is executed that downloads the source zip file, runs npm install to get he dependencies and then uploads the source+dependencies to S3 as a tarball.
  • gulp lambda(s) - a lambda is executed that downloads the source+dependencies tarball from S3, extracts it, then runs a gulp task

The details of what happens in the gulp task is completely owned by the gulpfile.js in the source code. This provides decoupling of the pipeline from the app and allows the pipeline template to be used by any gulp project.

pipeline-overview

Here's a sample of what the pipeline looks like in AWS CodePipeline console:

pipeline-example

Launching Pipeline

To integrate with GitHub, AWS CodePipeline uses OAuth tokens. Generate your token at GitHub and ensure you enable the following two scopes:

  • admin:repo_hook, which is used to detect when you have committed and pushed changes to the repository
  • repo, which is used to read and pull artifacts from public and private repositories into a pipeline

You can launch via the console: Launch Pipeline stack

Or you can launch by using gulp in this repo:

  • PREREQUISITES - You need Node.js installed.
    • Install Node.js: sudo yum install nodejs npm --enablerepo=epel (For OS X, check out nodejs.org)
    • Update NPM: curl -L https://npmjs.org/install.sh | sudo sh
    • Install Gulp: sudo npm install -g gulp
  • Download this repo and then run npm install first to install all dependent modules.
  • Bring the pipeline up with gulp pipeline:up --token=XXXXXXXXXXXXXXXXX
  • You can run gulp pipeline:wait to wait for the stack to come up, and then gulp pipeline:status to get the outputs and gulp pipeline:stacks to see what applicaiton stacks the pipeline has currently running.
  • To tear everything down, run gulp pipeline:teardown
  • By default, the stack name will be dromedary-serverless-pipeline. You can change this by passing --stackName=my-stack-name to any of the above gulp commands.

Development

To do local development of the CFN or Gulp tasks, you'll want to link in the submodules with npm run-script submodules

To publish your app template changes, run gulp app:cfn:publish. You will likely want to choose a different bucket to publish the templates and lambda code to via the --templateBucket argument. Be sure to then reference that same bucket name in your gulpfile.js for cfnBucket.

To publish your pipeline template/lambda changes, run gulp pipeline:cfn:publish. You will likely want to choose a different bucket to publish the templates and lambda code to via the --templateBucket argument. Be sure to then reference that same bucket name when you pipeline:up.

Todo

  • Tighten up IAM policies in CFN
  • Production deployment in pipeline
  • Extract out /app directory to generic module named gulp-serverless-app to enable running Express Node.js apps in AWS with Lambda and API Gateway.
  • Extract out /pipeline directory to generic module named gulp-serverless-pipeline to enable running CodePipeline with Gulp for other applications.