Skip to content

About

expose-cassandra-data

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Restful API Creation to extract Cassandra data

Description

Exposing the data from Cassandra DB running in an instance to external world by running a NodeJS server. The tools, frameworks and technologies involved are:

Installation

Initially check the version of node and npm.

$ npm --version
$ node --version

This package requires Node.js and ExpressJS to function. Initialize the npm module using $ npm init command.

Install the dependencies and devDependencies.

$ npm install -g express
$ npm install -g nodemon
$ npm install -g cassandra-driver

Check the installation of the packages using $ ls node_modules #(dir node_modules for windows)command

Steps

  1. Create the main.js file
$ vi main.js 
  1. Use this link in a straight-forward approach. For asynchronous calls use this link

  2. Replace the keyspace davekeyspace1 with your keyspace

  3. Optional Customization :

  • contactPoints (127.0.0.1)
  • Cassandra execute query (Select * from davetable)
  • Port number (3000)
  1. Run the $ nodemon --inspect main.js command to start the server

  2. Try hitting the endpoint youripaddress:port. eg., 54.54.204.204:3000

Response

The output is in json.

[{"emp_id":1,"emp_city":"Pondi","emp_name":"Lego"},
 {"emp_id":2,"emp_city":"Tripati","emp_name":"Dhana"},
 {"emp_id":3,"emp_city":"Trichi","emp_name":"Dave"}]

Response in Postman PostmanDiagram

Response on Browser PostmanDiagram

Troubleshooting

  1. If port number is occupied, then try $ killall -9 node
  2. To check if API works in local instance, try $ curl localhost:3000

Visualization

Some sample visualization achieved using the JSON (Built using Highchart) PostmanDiagram

PostmanDiagram

Contact

About

expose-cassandra-data

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages