# AssetChain Nodejs Shared Library

Set of shared components / libraries to help us writing node.js lambdas

## Install

```
npm i --save aws-sdk @assetchain/shared
```


## Breaking changes

#### 2.x
- `Logger.createLogger` is now async and returns a promise. 

```
// before 2.x
const log = Logger.createLogger();

// after 2.x
const log = await Logger.createLogger();

```

#### 2.4
- All SSM paths that contain illegal characters will be automatically replaced with an underscore "_"
```
/master/tenant/ap-southeast-2:6eefc452-f495-461a-ab4a-764073df12e9/slug 

to

/master/tenant/ap-southeast-2_6eefc452-f495-461a-ab4a-764073df12e9/slug
```

## Content

### `is` ([docs](https://github.com/JB-AssetChain/assetchain.nodejs.shared/blob/master/src/is/README.md))

Set of helpers to quickly check variable types

### `Logger` ([docs](https://github.com/JB-AssetChain/assetchain.nodejs.shared/blob/master/src/logging/README.md))

This logger library provides an easier way to initialise execution-wide AWS loggers that will share
the same metadata object within the lambda execution. 

### `ParameterDiscoveryService` ([docs](https://github.com/JB-AssetChain/assetchain.nodejs.shared/blob/master/src/parameter-store-discovery/))

Library that provides an easier access to AWS SSM Parameter store to use it
as a resilient distributed key/value storage for service discovery.

### `Correlation` ([docs](https://github.com/JB-AssetChain/assetchain.nodejs.shared/blob/master/src/correlation/))

Library that correlation id support based on Open Zipkin standard

## Publish

Bump the version number before merging into master.

Login (`npm login`) as assetchain user (check devadmin@getfu.com.au email) and publish it

```
npm publish --access public
```

## Development

Build this library using `npm build` - that will run eslint + prettier checks and unit tests

## License

The MIT License (MIT)
=====================

Copyright © 2018 AssetChain

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the “Software”), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
