GithubHelp home page GithubHelp logo

watson-developer-cloud / discovery-nodejs-static Goto Github PK

View Code? Open in Web Editor NEW
2.0 9.0 12.0 1.66 MB

Sample Node.js application that uses the IBM Watson Discovery Service

Home Page: https://discovery-news-demo-static.mybluemix.net/

JavaScript 82.33% Python 4.15% CSS 13.52%

discovery-nodejs-static's Introduction

Discovery Static News Demo Build Status

UNMAINTAINED: please use https://github.com/watson-developer-cloud/discovery-nodejs

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.mybluemix.net/

Getting started

  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. Edit the manifest.yml file and change <application-name> to something unique. The name you use determines the URL of your application. For example, <application-name>.mybluemix.net.

declared-services:
my-discovery:
  label: discovery
  plan: free
applications:
- name: discovery-news-demo
  command: npm start
  path: .
  memory: 512M
  services:
    - my-discovery-service
  1. Connect to Bluemix with the command line tool.
cf api https://api.ng.bluemix.net
cf login
  1. Create and retrieve service keys to access the Discovery service:
cf create-service discovery free my-discovery-service
cf create-service-key my-discovery-service myKey
cf service-key my-discovery-service myKey
  1. Use the credentials that are returned in step 5 to retrieve the IBM curated News environment_id from the list of environments:
curl -X GET -u <username>:<password> https://gateway.watsonplatform.net/discovery/api/v1/environments?version=2016-11-07

Output:

{
  "environments": [{
    "created": "2016-11-30T15:41:22.298Z",
    "description": "Watson News cluster environment",
    "environment_id": "bb6ffe96-53d5-44b3-8838-922d4665df8d",
    "index_capacity": {
      ...
    },
    "memory_usage": {
      ...
    },
    "name": "Watson News Environment",
    "read_only": true,
    "status": "active",
    "updated": "2016-11-30T15:41:22.298Z"
  }]
}
  1. Use the environment_id from step 6 to retrieve the IBM curated News collection_id from the list of collections:
curl -X GET -u <username>:<password> https://gateway.watsonplatform.net/discovery/api/v1/environments/<environment_id>/collections?version=2016-11-07

Output:

{
  "collections": [
    {
      "collection_id": "0288e2a0-a1c1-4a38-a376-3c3bd89e927b",
      "description": "Watson News T3 collection",
      "name": "v5-fullnews-t3-2016",
      "configuration_id": "f916ddcd-961e-4668-b46b-2b0f9fe8f002",
      "language": "en_us",
      "status": "active",
      "created": "2016-11-30T15:41:22.318Z",
      "updated": "2016-11-30T15:41:22.318Z"
    }
  ]
}
  1. 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, your environment_id, and your collection_id that you retrieved in steps 5 to 7.

The .env file will look something like the following:

DISCOVERY_USERNAME=<username>
DISCOVERY_PASSWORD=<password>

DISCOVERY_HOST=gateway.watsonplatform.net

DISCOVERY_ENVIRONMENT=<environment_id>
DISCOVERY_COLLECTION=<collection_id>
  1. Install the needed application dependencies with this command:
npm install
  1. Start the application locally (using Node version 6.0 or greater):
npm start
  1. Point your browser to http://localhost:3000.

  2. When you're ready, push the application to Bluemix with this command:

cf push

After completing these steps, you are ready to test your application. Start a browser and enter the URL of your application.

        <application-name>.mybluemix.net

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

Troubleshooting

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

    cf logs <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
├── manifest.yml
├── package.json
├── public                      // static resources
├── server.js                   // entry point
├── test                        // tests
└── views                       // react components

License

This sample code is licensed under Apache 2.0.

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 Bluemix 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)
  • Space ID (space_id)
  • Application Version (application_version)
  • Application URIs (application_uris)
  • Labels of bound services
  • Number of instances for each bound service and associated plan information

This data is collected from the package.json file in the sample application and the VCAP_APPLICATION and VCAP_SERVICES environment variables in IBM Bluemix and other Cloud Foundry platforms. This data is used by IBM to track metrics around deployments of sample applications to IBM Bluemix 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.

discovery-nodejs-static's People

Contributors

germanattanasio avatar jzhang300 avatar kcheat avatar kognate avatar maniax89 avatar sirspidey avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

discovery-nodejs-static's Issues

[discovery] discovery-client.js

discovery-client.js needs "use strict" in the first line for successful compilation.
"npm start" failed at my end (localhost) for the original code. This was the error:
Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
It got resolved when I added "use strict" in the first line of that file. Is it just me or are other having an issue too?

Add telium

We need to make sure the demo loads

function loadAnalytics() {
  var idaScript = document.createElement('script');
  idaScript.src = '//www.ibm.com/common/stats/ida_stats.js';
  document.head.appendChild(idaScript);
}

window.addEventListener('load', loadAnalytics);

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.