# @ibm-watson/discovery-nodejs

> Discovery sample application

Latest version **1.0.2** (published 2019-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ibm-watson/discovery-nodejs
pnpm add @ibm-watson/discovery-nodejs
yarn add @ibm-watson/discovery-nodejs
bun add @ibm-watson/discovery-nodejs
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; large bundle.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2019-11-07 |
| First published | 2018-09-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=12.0 |
| Dependencies | 16 |
| Unpacked size | 57.1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 77 |
| Author | IBM Corp. |
| Maintainers | ehdsouza, germanattanasio, jsstylos, lpatino10, mamoonraja, maniax89 |

## Links

- npm: https://www.npmjs.com/package/@ibm-watson/discovery-nodejs
- Repository: https://github.com/watson-developer-cloud/discovery-nodejs
- Homepage: https://github.com/watson-developer-cloud/discovery-nodejs#readme
- Issues: https://github.com/watson-developer-cloud/discovery-nodejs/issues
- npm.io page: https://npm.io/package/@ibm-watson/discovery-nodejs

## Dependencies (16)

- [react](https://npm.io/package/react.md) ^16.11.0
- [dotenv](https://npm.io/package/dotenv.md) ^8.2.0
- [helmet](https://npm.io/package/helmet.md) ^3.21.2
- [moment](https://npm.io/package/moment.md) ^2.24.0
- [morgan](https://npm.io/package/morgan.md) ^1.9.1
- [express](https://npm.io/package/express.md) ^4.17.1
- [recharts](https://npm.io/package/recharts.md) ^1.8.5
- [react-dom](https://npm.io/package/react-dom.md) ^16.11.0
- [classnames](https://npm.io/package/classnames.md) ^2.2.5
- [ibm-watson](https://npm.io/package/ibm-watson.md) ^5.1.0
- [prop-types](https://npm.io/package/prop-types.md) ^15.7.2
- [body-parser](https://npm.io/package/body-parser.md) ^1.19.0
- [cross-spawn](https://npm.io/package/cross-spawn.md) ^7.0.1
- [express-rate-limit](https://npm.io/package/express-rate-limit.md) ^5.0.0
- [express-secure-only](https://npm.io/package/express-secure-only.md) ^0.2.1
- [watson-react-components](https://npm.io/package/watson-react-components.md) ^0.6.19

## Recent versions

- 1.0.2 (latest) — 2019-11-07
- 1.0.1 — 2018-11-19
- 1.0.0 — 2018-09-24

## README

<h1 align="center" style="border-bottom: none;">🔎 Discovery Demo </h1>
<h3 align="center">Use the IBM Watson Discovery service to add a cognitive search and content analytics engine to your applications to identify patterns, trends and actionable insights that drive better decision-making.</h3>
<p align="center">
  <a href="http://travis-ci.org/watson-developer-cloud/discovery-nodejs">
    <img alt="Travis" src="https://travis-ci.org/watson-developer-cloud/discovery-nodejs.svg?branch=master">
  </a>
  <a href="#badge">
    <img alt="semantic-release" src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg">
  </a>
</p>
</p>

![demo](readme-images/new-demo.gif)

Demo: https://discovery-news-demo.ng.bluemix.net/

## Prerequisites

1. Sign up for an [IBM Cloud account](https://console.bluemix.net/registration/).
1. Download the [IBM Cloud CLI](https://console.bluemix.net/docs/cli/index.html#overview).
1. Create an instance of the Discovery service and get your credentials:
    - Go to the [Discovery](https://console.bluemix.net/catalog/services/discovery) page in the IBM Cloud Catalog.
    - Log in to your IBM Cloud account.
    - Click **Create**.
    - Click **Show** to view the service credentials.
    - Copy the `apikey` value, or copy the `username` and `password` values if your service instance doesn't provide an `apikey`.
    - Copy the `url` value.

## Configuring the application

1. In the application folder, copy the *.env.example* file and create a file called *.env*

    ```
    cp .env.example .env
    ```

2. Open the *.env* file and add the service credentials that you obtained in the previous step.

    Example *.env* file that configures the `apikey` and `url` for a Discovery service instance hosted in the US East region:

    ```
    DISCOVERY_IAM_APIKEY=X4rbi8vwZmKpXfowaS3GAsA7vdy17Qh7km5D6EzKLHL2
    DISCOVERY_URL=https://gateway-wdc.watsonplatform.net/discovery/api
    ```

    - If your service instance uses `username` and `password` credentials, add the `DISCOVERY_USERNAME` and `DISCOVERY_PASSWORD` variables to the *.env* file.

    Example *.env* file that configures the `username`, `password`, and `url` for a Discovery service instance hosted in the Sydney region:

    ```
    DISCOVERY_USERNAME=522be-7b41-ab44-dec3-g1eab2ha73c6
    DISCOVERY_PASSWORD=A4Z5BdGENrwu8
    DISCOVERY_URL=https://gateway-syd.watsonplatform.net/discovery/api
    ```

<!-- **ADD ANY APP-SPECIFIC CONFIGURATION INSTRUCTIONS HERE** -->

## Running locally

1. Install the dependencies

    ```
    npm install
    ```

1. Build the application

    ```
    npm run build
    ```

1. Run the application

    ```
    npm start
    ```

1. View the application in a browser at `localhost:3000`

## Deploying to IBM Cloud as a Cloud Foundry Application

1. Build the application

    ```
    npm run build
    ```

1. Login to IBM Cloud with the [IBM Cloud CLI](https://console.bluemix.net/docs/cli/index.html#overview)

    ```
    ibmcloud login
    ```

1. Target a Cloud Foundry organization and space.

    ```
    ibmcloud target --cf
    ```

1. Edit the *manifest.yml* file. Change the **name** field to something unique. For example, `- name: my-app-name`.
1. Deploy the application

    ```
    ibmcloud app push
    ```

1. View the application online at the app URL, for example: https://my-app-name.mybluemix.net


## Tests

#### Unit tests
Run unit tests with `npm run test-unit`, then `a` to run all tests. See the output for more info.

#### Integration tests
First you have to make sure your code is built: `npm run build`

Then run integration tests with: `npm run test-integration-runner`

## Directory structure

```none
.
├── app.js                      // express routes
├── config                      // express configuration
│   ├── error-handler.js
│   ├── express.js
│   └── security.js
├── package.json
├── public                      // static resources
├── server.js                   // entry point
├── test                        // integration tests
└── src                         // react client
    ├── __test__                // unit tests
    └── index.js                // app entry point
```

## License

  This sample code is licensed under the [MIT License](https://opensource.org/licenses/MIT).

## Contributing

  See [CONTRIBUTING](.github/CONTRIBUTING.md).

## Open Source @ IBM
  Find more open source projects on the [IBM Github Page](http://ibm.github.io/)

[getting_started]: https://www.ibm.com/watson/developercloud/doc/common/index.html
[docs]: http://www.ibm.com/watson/developercloud/doc/discovery/index.html
[sign_up]: https://console.ng.bluemix.net/registration/

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