# funcional

> Simplify working with Google Cloud Platform functions

Latest version **0.2.0-alpha.3** (published 2019-03-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install funcional
pnpm add funcional
yarn add funcional
bun add funcional
```

## 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.2.0-alpha.3 |
| Published | 2019-03-24 |
| First published | 2018-02-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.0.0 |
| Dependencies | 2 |
| Unpacked size | 8.9 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | José Carneiro |
| Maintainers | josecarneiro |

## Links

- npm: https://www.npmjs.com/package/funcional
- Repository: https://github.com/josecarneiro/funcional
- npm.io page: https://npm.io/package/funcional

## Dependencies (2)

- [request](https://npm.io/package/request.md) ^2.88.0
- [request-promise-native](https://npm.io/package/request-promise-native.md) ^1.0.7

## Recent versions

- 0.2.0-alpha.3 (latest) — 2019-03-24
- 0.2.0-alpha.1 (alpha) — 2019-02-17
- 0.2.0-alpha.2 — 2019-02-17
- 0.2.0-alpha.0 — 2019-02-16
- 0.1.1 — 2018-11-29
- 0.1.0 — 2018-02-16

## README

# `funcional`

Requires node version `8.x.x`. The compatibility of this library should match the node LTS release schedule, since that is the version used by Google Cloud Functions.

## Remote

Should be used in the remote cloud function.

The constructor can be initiated with a `handler` and an optional `options` object.

The handler function should be declared as `async` **or** return a `Promise`. It takes the arguments `instance` and an object composed of the original http request and response.

### Sample usage

index.js hosted on Google Cloud Functions:

```js
  const Remote = require('funcional/remote');

  const handler = async (instance) => {
    const body = instance.body;
    return { formatted: body.name.toUpperCase().split(' ').join('-') };
  };

  exports.http = new Remote(handler).handle;
```

## Local

To be used on the server-side and communicate with the remote function.

### Sample Usage

```js
  const Local = require('funcional/local');

  const local = new Local({
    region: 'example-gcp-region',
    project: 'example-project',
    name: 'example-function-name'
  });

  const communicate = async (data) => {
    try {
      const response = await local.send(data);
      console.log(response); // holds the response body from the function
      console.log(local.meta); // meta holds meetadata from the execution of the remote function
    } catch (error) {
      // ... handle error
    }
  };

  communicate({ name: 'James Dean' });
  // { formatted: 'JAMES-DEAN' }
```

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