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

@cactus-tech/build-serverless

v1.1.1

Published

This package helps to integrate ES6 NodeJS projects with AWS Lambda (SAM CLI) by compiling the source code with babel and copying other miscellaneous & configuration file to the build directory.

Downloads

16

Readme

Build Serverless

npm-image

Building for serverless

Node.js package for transpiling source code for AWS SAM(AWS Serverless) for integration with AWS Lambda & AWS API Gateway using AWS sam-cli from your nodejs project.

Since AWS Lambda officially only supports Node.js 12.x runtime, This package helps in converting ES6 source to es2015 node.js code to be used by sam build

Usage

This package transpiles ES6 node.js code using @babel/cli to native node.js code to be used with sam build of aws sam-cli tool.

The package supports both programatical and cli interface.

CLI

To use cli interface run the below command from the root directory of the project.

$ npx @cactus-tech/build-serverless -o <dir-name> [options]

Run the following command to get the see other options available.

$ npx @cactus-tech/build-serverless --help
build-serverless -o <dir-name> [options]

Options:
      --version              Show version number                                                                                                                               [boolean]
  -o, --output-dir           name of output dir for compiled code                                                                                                    [string] [required]
  -s, --source-dir           source code directory                                                                                                             [string] [default: "src"]
  -n, --service-name         name of the microservice                                                                                            [string] [default: "your service name"]
  -d, --service-description  description of the microservice                                                                                 [string] [default: "your description here"]
  -c, --copy-files           list of files to copy to output dir
                                              [array] [default: [".env",".eslintrc.json",".eslintignore",".babelrc",".prettierrc",".prettierignore","package.json","package-lock.json"]]
      --help                 Show help                                                                                                                                         [boolean]

It needs a dirname for the output code, serverless- is appended to the output dirname automatically. Then it complies the code using babel and copies all the files from the source-dir mentioned using the --source-dir flag. All files present in the source-dir directory will be copied to output-dir, if any other files are required to be copied they need to be added using the --copy-files flag.

Example

This example demonstrates compiling .js files from src/ folder and output it into example directory. also copying .env, .babelrc, package.json files are explictly copied to the output directory.

 $ npx build-serverless --output-dir example --source-dir src --copy-files .env .babelrc package.json --service-name 'service name' --service-description 'service description'

API

Installation

$ npm install @cactus-tech/build-serverless

To use the package programmatically, this package also exposes an api for integrating with other programs.

const buildServerless = require("@cactus-tech/build-serverless");

The buildServerless class takes the following parameters for it's constructor and exposes init() method.

const buildServerless = new BuildServerless({
  outputDir: "example",
  sourceDir: "src",
  copyFiles: [".env",".babelrc","package.json"],
  serviceName: "service name",
  serviceDescription: "service description",
});

(async () => {
  try {
    await buildServerless.init();
  } catch (error) {}
})();

It also generates template.yaml file in the root directory and a lambda.js file in the output-dir.