Skip to content

Commit

Permalink
Merge pull request #1 from marcelobern/master
Browse files Browse the repository at this point in the history
Improved documentation
  • Loading branch information
marcelobern committed Dec 19, 2018
2 parents 585ee3f + bcd6d54 commit 244b5ce
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 32 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Changelog

### 0.0.1 (Next)

* Improved documentation readability - [@marcelobern](https://github.com/marcelobern).
61 changes: 31 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
# lambda-bin
[![Build Status](https://travis-ci.org/botbits/lambda-bin.svg?branch=master)](https://travis-ci.org/botbits/lambda-bin)
[![Coverage Status](https://coveralls.io/repos/github/botbits/lambda-bin/badge.svg?branch=master)](https://coveralls.io/github/botbits/lambda-bin?branch=master)
[![NPM Version](https://img.shields.io/npm/v/lambda-bin.svg)](https://www.npmjs.com/package/lambda-bin)
[![Build Status](https://travis-ci.com/botbits/lambda-bin.svg?branch=master)](https://travis-ci.com/botbits/lambda-bin)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/517072359191415cbc9d00e44a73997f)](https://www.codacy.com/app/marcelobern/lambda-bin?utm_source=github.com&utm_medium=referral&utm_content=botbits/lambda-bin&utm_campaign=Badge_Grade)
[![Coverage Status](https://coveralls.io/repos/github/botbits/lambda-bin/badge.svg?branch=master)](https://coveralls.io/github/botbits/lambda-bin?branch=master)
[![Known Vulnerabilities](https://snyk.io/test/github/botbits/lambda-bin/badge.svg?targetFile=package.json)](https://snyk.io/test/github/botbits/lambda-bin?targetFile=package.json)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fbotbits%2Flambda-bin.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fbotbits%2Flambda-bin?ref=badge_shield)

> Add non-standard binaries to serverless compute.
This module reduces the footprint of the run-time only part of the [`bin-minify`](https://github.com/botbits/bin-minify#readme) module and adds a few [AWS Lambda](https://aws.amazon.com/lambda/) specific functions.
## Overview

Still, this module's core functionality should work well for other serverless providers as well. [Please open an issue](https://github.com/botbits/lambda-bin/issues) if you come across limitations using this module with other serverless providers.
This module reduces the footprint of the *run-time* only part of the [bin-minify](https://www.npmjs.com/package/bin-minify) module and adds a few [AWS Lambda](https://aws.amazon.com/lambda/) specific functions.

Still, this module's core functionality should work well for other serverless providers as well. [Please open an issue](https://github.com/botbits/lambda-bin/issues) if you come across limitations using this module with other serverless providers.

## Install

```
```shell
$ npm install --save lambda-bin
```


## Usage

```js
Expand Down Expand Up @@ -46,7 +49,6 @@ myLambdaBin.applyMinPack(MY_LAMBDA_BIN_PATH).then((result) => {
});
```


## API

### constructor (options)
Expand All @@ -56,53 +58,49 @@ Object new LambdaBin( Object )

#### options

Type: `Object`

Optional
- Type: `Object`
- Optional

The following are supported keys in the `options` `json` object. Any other keys are ignored.
The following are supported keys in the `options` JSON object. Any other keys are ignored.

##### targetPath

Type: `string`

Default: `./bin/bin-minify`
- Type: `string`
- Default: `./bin/bin-minify`

Location of the actual binaries.

**Note**: Typically the binaries under `targetPath` are source controlled (and should be included in the `npm` module or `Lambda` package).
**Note**: Typically the binaries under `targetPath` are source controlled (and should be included in the npm module or Lambda package).

##### useSymlinks

Type: `boolean`
- Type: `boolean`

Any value passed will be replaced with `false`, which is required for `bin-minify` to work on `AWS Lambda`

##### minPack

Type: `Object`
- Type: `Object`
- Default: `{}`

Default: `{}`
Used to *load* a previously created ***minPack***.

Used to ***load*** a previously created `minPack`.

**Note**: A `minPack` is created using [`bin-minify stagingBin.createMinPack()`](https://www.npmjs.com/package/bin-minify#promise-stagingbincreateminpack-) and saved to a source controlled file (which should be included in the `npm` module or `Lambda` package).
**Note**: A `minPack` is created using [`bin-minify stagingBin.createMinPack()`](https://www.npmjs.com/package/bin-minify#promise-stagingbincreateminpack-) and saved to a source controlled file (which should be included in the npm module or Lambda package).

### Promise runtimeBin.applyMinPack (fromBase)

#### fromBase

Type: `string`

Required
- Type: `string`
- Required

Base path where the original file structure of the binaries will be recreated.

#### returns Promise

Resolved Promise: `{ loaded: true or false }`. `loaded` will be:
- `true` if the file structure was successfully created.
- `false` if the `fromBase` path already existed.
- `true` if the file structure was successfully created.
- `false` if the `fromBase` path already existed.

Rejected Promise: `{ error }`.

Expand All @@ -112,7 +110,7 @@ Once the original file structure of the binaries is recreated, it is necessary t

#### pathsToAdd

Type: `string` or `Array`
- Type: `string` or `Array`

The path(s) for the binaries. Typically these paths are children of `fromBase` and/or `fromBase` itself.

Expand All @@ -128,18 +126,21 @@ Some binaries rely on environment variables to control their behavior (e.g. `NOD

#### variablesToSet

Type: `Object`
- Type: `Object`

Key-values pairs representing the environment variables to add/change, where the `key` is the environment variable name and the `value` its associated value.
Key-values pairs representing the environment variables to add/change, where the *key* is the environment variable name and the *value* its associated value.

#### shouldOverwrite

Type: `boolean`
- Type: `boolean`

If `true`, any existing value will be replaced. If `false` the value provided will be appended to any existing value using ':'.

**Tip**: If it necessary to overwrite and append values, call `setEnv()` twice and change the value of `shouldOverwrite` accordingly.

## AWS Lambda Limits

Please keep these [AWS lambda limits](https://docs.aws.amazon.com/lambda/latest/dg/limits.html) in mind when deploying lambda functions.

## License

Expand Down
Empty file added UPGRADING.md
Empty file.
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,19 @@
"url": "https://github.com/botbits/lambda-bin/issues"
},
"homepage": "https://github.com/botbits/lambda-bin#readme",
"author": "BotBits (https://github.com/botbits/)",
"author": "BotBits (sm) (https://github.com/botbits)",
"keywords": [
"serverless",
"binary",
"aws",
"lambda"
"lambda",
"filesystem",
"fs",
"minify",
"compact",
"pack",
"package",
"bin-minify"
],
"engines": {
"node": ">=6"
Expand Down

0 comments on commit 244b5ce

Please sign in to comment.