Git Product home page Git Product logo

webservice's Introduction

Web Service

Project Description

Welcome to this awesome web service! It was build using Node.js, Express.js, and InfluxDB.

Requirements

You need to have Node.js on your computer. If you do not have it, you can install it here. I recommend you to install the LTS version.

Steps To Get Started

Follow the next steps to get started:

  1. Download InfluxDB Time-Series Data Storage v1.7.4

    You can download it here

  2. Download this repository

    $ git clone https://github.com/japoveda10/webservice.git

  3. Open a terminal window, and go inside the webservice folder

    $ cd webservice

  4. Install the required dependencies

    $ sudo npm install

  5. Now, run the InfluxDB server:

    $ influxd

  6. Open a new terminal window (do not close the other one) and run the next command to have access to the InfluxDB Command Line Interface:

    $ influx

  7. In that terminal window, you should see a ">". If so, enter the following and hit enter:

    $ CREATE DATABASE monitor

  8. Open a new terminal window (do not close the other two) and make sure you are inside the webservice folder. Then, run:

    $ node app.js

    If you have nodemon installed, you can also run:

    $ nodemon app.js

    Nodemon restarts the server when it detects changes in app.js. If you do not have Nodemon installed on your computer, you can run the following command to install it globally on your computer:

    $ npm install -g nodemon

  9. Now you are ready to test endpoints!

InfluxDB

InfluxDB is an open source Time Series database. It is written in Go and has various optimizations. The database this web service uses is called monitor. It has 2 measurements (or tables in the Relational Databases world vocabulary):

  • historical
  • device_state

Each measurement has fields and tags. Fields are key-value pairs of something measured and tags contain metadata. Tags are indexed while fields are not.

For the historical measure:

  • Tags

    • id
    • deviceId
    • deviceInstanceId
    • host
    • region
    • release
    • releaseId
    • software
  • Fields

    • cpu (VARCHAR)
    • frequencyOfDataTransmission (VARCHAR)
    • networkIn (VARCHAR)
    • networkOut (VARCHAR)
    • ram (VARCHAR)

For the device_state measure:

  • Tags

    • id
    • deviceId
    • deviceInstanceId
    • host
    • region
    • release
    • software
  • Fields

    • state (VARCHAR)

Test endpoints

This is the home endpoint:

You can try the next endpoints for the historical measure. Remember to change :id by a number.

Example of a POST request body:

{
    "cpu": "cpu 1",
    "deviceId": 1,
    "deviceInstanceId": 1,
    "frequencyOfDataTransmission": "frequency of data transmission 1",
    "host": "host 1",
    "networkIn": "network in 1",
    "networkOut": "network out 1",
    "ram": "ram 1",
    "region": "region 1",
    "release": "release 1",
    "releaseId": 1,
    "software": "software 1"
}

You can try the next endpoints for the device_state measure. Remember to change :id by a number.

Example of a POST request body:

{
    "deviceId": 1,
    "deviceInstanceId": 1,
    "host": "host 1",
    "region": "region 1",
    "release": "release 1",
    "software": "software 1",
    "state": "state 1"
}

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.