0.3.0 • Published 4 years ago

js2faas v0.3.0

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

js2faas

JS Transpiler to port your code to Google, Amazon & IBM FaaS

Install

npm i js2faas -g

Basic Usage

Make sure you're calling js2faas in the directory of the function you want to port.

$ js2faas OPTIONS... 
  
  Options
    --name FUNCTIONNAME 
    --runtime 'nodejs8' | 'nodejs10' | 'latest'
    --entry-file FNAME # default-export your entry point in here
    --aws-role AWSROLEARN

js2faas will transpile your JS code it finds in the current directory, and put it into the newly created folders amazon, google and ibm, respectively. NPM dependencies are supported.

Deploy your code

To Amazon Lambda

cd amazon
npm run create # afterwards, npm run update

To Google Cloud Functions

cd google
npm run deploy

To IBM Functions

cd ibm
npm run deploy

Example

├── index.js
├── node_modules
├── package.json
└── package-lock.json

Let's say your entry point is index.js:

// default-export your entry point
module.exports = (event) => {
 console.log(`Data passed: ${ event }`);
 return { a: 1, b: 2 }
}

If your function returns something, it must be a JavaScript Object, like in the code above.

Run js2faas

js2faas
  --name newFuncName
  --entry-file index.js
  --runtime nodejs10
  --aws-role xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
├── index.js
├── node_modules
├── package.json
├── package-lock.json
|
├── amazon
├── google
└── ibm

Deploy the function

cd amazon
sh create.sh  # afterwards, sh update.sh

# --

cd google
sh deploy.sh

# -- 

cd ibm
sh deploy.sh

Licence

Apache 2.0

0.3.0

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago