# hyperform-dev

> Tiny API to run JS code on any FaaS

Latest version **0.3.0** (published 2021-01-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install hyperform-dev
pnpm add hyperform-dev
yarn add hyperform-dev
bun add hyperform-dev
```

Provides the command `js2faas`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2021-01-17 |
| First published | 2021-01-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10.2.0 |
| Dependencies | 5 |
| Unpacked size | 25.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | qngapparat |
| Maintainers | jakob.wallnoefer |

## Links

- npm: https://www.npmjs.com/package/hyperform-dev
- Homepage: https://github.com/qngapparat/hyperform-dev
- npm.io page: https://npm.io/package/hyperform-dev

## Dependencies (5)

- [arg](https://npm.io/package/arg.md) ^4.1.2
- [tmp](https://npm.io/package/tmp.md) ^0.2.1
- [chalk](https://npm.io/package/chalk.md) ^4.1.0
- [fs-extra](https://npm.io/package/fs-extra.md) ^8.1.0
- [prettier](https://npm.io/package/prettier.md) ^2.0.5

## Recent versions

- 0.3.0 (latest) — 2021-01-17

## README

# js2faas

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

## Code requirements

➡️ Your entry point must be in `index.js` and be default-exported, for instance `module.exports = (event) => { /* ... */ }`

➡️ It will receive exactly one argument, the invocation payload (commonly called `event`)

➡️ If your code returns something, it must be an `Object`, or a `Promise` thereof

## Install

Requires NodeJS >= 10.2.0

```shell
npm i js2faas -g
```

## Basic Usage

```shell
$ js2faas OPTIONS... 
  
  Options
    --name FUNCTIONNAME 
    --runtime 'nodejs8' | 'nodejs10' | 'latest'
    --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

```shell
cd amazon
npm run create # afterwards, npm run update
```

### To Google Cloud Functions

```shell
cd google
npm run deploy
```

### To IBM Functions

```shell
cd ibm
npm run deploy
```


## Example

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

Let's look into our `index.js`:
```js
// default-export your entry point
module.exports = (event) => {
 console.log(`Data passed: ${ event }`);
 return { a: 1, b: 2 }
}
```


Run `js2faas`
```shell
js2faas
  --name newFuncName
  --runtime nodejs10
  --aws-role xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```

```
├── index.js
├── node_modules
├── package.json
├── package-lock.json
|
├── amazon
├── google
└── ibm
```

Deploy the function

Make sure you have installed the respective CLI tools (`aws`, `gcloud`, `ibm`) and have configured them. Otherwise the scripts will not know where to deploy to. Credentials are **not** baked into the folders.

```sh
cd amazon
sh deploy.sh  # afterwards, sh update.sh

# --

cd google
sh deploy.sh

# -- 

cd ibm
sh deploy.sh
```


## Licence

Apache 2.0

---
_Source: https://npm.io/package/hyperform-dev · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
