0.3.0 • Published 5 years ago
js2faas v0.3.0
js2faas
JS Transpiler to port your code to Google, Amazon & IBM FaaS
Install
npm i js2faas -gBasic 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 AWSROLEARNjs2faas 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 updateTo Google Cloud Functions
cd google
npm run deployTo IBM Functions
cd ibm
npm run deployExample
├── index.js
├── node_modules
├── package.json
└── package-lock.jsonLet'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
└── ibmDeploy the function
cd amazon
sh create.sh # afterwards, sh update.sh
# --
cd google
sh deploy.sh
# --
cd ibm
sh deploy.shLicence
Apache 2.0