Giter VIP home page Giter VIP logo

discovery-nodejs's Introduction

Discovery Demo Build Status

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.

Demo

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

Getting started

To deploy this repository as-is, click the "Deploy to IBM Cloud" button

Deploy to IBM Cloud

When this button is clicked, it will begin the process of creating a deployment toolchain based on the master branch of the repo into Bluemix and you will have to modify the application name to the name of the host you want to put it at. The default will get mapped to {organization/user}-{repo_name}-{timestamp}.

After creating the toolchain, you must either run the deployment script as part of the Continuous Delivery which will create the service for you, or refer to the Setup a IBM Watson Discovery Service section below to create it manually.

For more details about developing applications that use Watson Developer Cloud services in Bluemix, see Getting started with Watson Developer Cloud and Bluemix.

Development

Setup a IBM Watson Discovery Service

  1. You need a Bluemix account. If you don't have one, sign up.

  2. Download and install the Cloud-foundry CLI tool if you haven't already.

  3. Connect to Bluemix with the command line tool.

    cf api https://api.ng.bluemix.net
    cf login
  4. Create and retrieve service keys to access the Discovery service:

    cf create-service discovery standard Discovery-Demo
    cf create-service-key Discovery-Demo myKey
    cf service-key Discovery-Demo myKey
    
  5. Create an .env file in the root directory by copying the sample .env.example file using the following command:

    cp .env.example .env
    

    Update the .env with your service instance information from step 4

    The .env file will look something like the following:

    DISCOVERY_USERNAME=<username>
    DISCOVERY_PASSWORD=<password>
    

Run the demo locally

  1. Install the needed application dependencies with this command:

    npm install
    
  2. Start the application locally:

    npm start
    
  3. Point your browser to http://localhost:3000.

You may build the optimized production build by running npm run build. Then you only require to run the node server.js to see your code hosted at http://localhost:5000

Run 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

Troubleshooting

  • The main source of troubleshooting and recovery information is the Bluemix log. To view the log, run this command:

    cf logs <your application name> --recent
  • For more details about the service, see the documentation for the Discovery service.


Directory structure

.
├── 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.

Contributing

See CONTRIBUTING.

Open Source @ IBM

Find more open source projects on the IBM Github Page

Privacy Notice

Sample web applications that include this package may be configured to track deployments to IBM Cloud and other Cloud Foundry platforms. The following information is sent to a Deployment Tracker service on each deployment:

  • Node.js package version
  • Node.js repository URL
  • Application Name (application_name)
  • Application GUID (application_id)
  • Application instance index number (instance_index)
  • Space ID (space_id) or OS username
  • Application Version (application_version)
  • Application URIs (application_uris)
  • Cloud Foundry API (cf_api)
  • Labels of bound services
  • Number of instances for each bound service and associated plan information
  • Metadata in the repository.yaml file

This data is collected from the package.json and repository.yaml file in the sample application and the VCAP_APPLICATION and VCAP_SERVICES environment variables in IBM Cloud and other Cloud Foundry platforms. This data is used by IBM to track metrics around deployments of sample applications to IBM Cloud to measure the usefulness of our examples, so that we can continuously improve the content we offer to you. Only deployments of sample applications that include code to ping the Deployment Tracker service will be tracked.

If you want to disable deployment tracking, follow these steps:

  • Set the environment variable DEMO_DEPLOY to 1 OR
  • remove the tracker.track(); line in the ./server.js file

discovery-nodejs's People

Contributors

maniax89 avatar zachary-dernar avatar germanattanasio avatar kognate avatar jeanlange avatar sirspidey avatar atambo avatar ehdsouza avatar maheshppibm avatar savitanagaraj avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.