[![codecov](https://codecov.io/gh/gesundheitscloud/hc-sdk-js/branch/master/graph/badge.svg?token=FcHHp38bcr)](https://codecov.io/gh/gesundheitscloud/hc-sdk-js)

# GesundheitsCloud Web SDK

This is the Javascript Web SDK of GesundheitsCloud, which encapsulates the backend functionality of the platform and enables end-to-end encryption of patient data. It allows users to store sensitive health data on the secure GesundheitsCloud platform and share it to authorized people and applications.

For more information about the platform please visit our [website](http://www.data4life.care/).

For more information about using the endpoints and methods provided by the SDK, read the documents in the `docs` folder in this repository.

## Requirements

To use the SDK, you need to create a client id from GesundheitsCloud. Please get in touch with us at info@data4life.care.

## Development and build

### Prerequisites

- node, npm (please don't use yarn)

In the directory run:

```bash
npm install
```

### Building
This SDK uses webpack for its bundling task.
Building the SDK bundle is done with:

```bash
 npm run build
```

Note the following options.

```bash
 npm run build:prod
```

This will add minification to the generated files.

```bash
 npm run build:local
 npm run build:prod:local
```

We use webpack chunking for performance reasons. On any non-local environment, these chunks are deployed to and fetched from our CDN. During development, however, webpack will fetch them from the same local path as the generated bundle with the `local` option.

### Watching

During development, you can let webpack watch for file changes and rebuild your bundle using:

```bash
npm run watch
```

Import the built file in your project to start using the SDK.

## Tests

The SDK uses karma, mocha, sinon, and chai for unit tests.

To run all tests, execute:

```bash
npm test
```

It uses eslint and tslint to check and report incorrect indentations and patterns in the project, bundles the project, run unit tests and makes a coverage report.

To run the unit tests only, execute:

```bash
npm run karma:prod
```

During development, you can watch for any file changes and rerun the tests on any change using:

```bash
npm run karma
```

To run eslint and tslint execute:

```bash
npm run lint
```

To run only eslint execute:

```bash
npm run eslint
```

To run only tslint execute:

```bash
npm run tslint
```

## Local server

** Currently not available **

To start a local test server, execute:

```
$ cd example
$ npm run start
```

This will start a sample app pointing to the staging environment with a predetermined client id for demo purposes.
On successful startup, open the browser pointing to http://localhost:8080/.
