Giter Site home page Giter Site logo

sensorweb-server's Introduction

SensorWeb server

License Build Status Coverage Status CircleCI

Usage

Before running the server, you will need to install all its dependencies via

npm install

The server requires some initial configuration before being able to run. You can create your configuration file in config/{NODE_ENV}.json. Take config/sample.json as a starting point for your config file.

The server uses PostgreSQL as the database system, so make sure that you have it installed and running on your machine. If you are on a Mac, you can try running scripts/bootstrap-mac.sh to install and launch PostgreSQL with the default configuration.

Once all dependencies are installed and the config file is in place you can start the server by running:

npm start

The server should start running at http://localhost:8080

Running the tests

npm run test-watch

sensorweb-server's People

Contributors

ferjm avatar julienw avatar fabricedesre avatar mostlygeek avatar albertopq avatar

Stargazers

Erdong avatar Till Riedel avatar Werner Keil avatar

Watchers

 avatar  avatar James Cloos avatar  avatar Dylan Oliver avatar

sensorweb-server's Issues

Use common's functions where possible

In #47 there is a new common.js file whose goal is to build a toolkit for the most current operations. The goal is to use it for all needed set-up in the tests.

Be careful: do not use it for the actual tested behavior. For example, do not use common's loginAsAdmin if you're actually testing the admin login. Use it only when it's not the test's subject and it's merely a setup step to the test.

Get rid of basic authentication

Instead of using basic authentication for the admin user, it would be safer to use the OAuth based flow being implemented in #24 and have a list of allowed admin users.

Provide a gettime endpoint

The sensors need a time synchronization source, and we have been advised to not use a ntp server, but rather to rely on a simple https service.

The ideal return value for us would be the number of seconds since epoch.

Analytics

Add analytics, for example, requests per second, to support the beta release of the API.

Calculate new AWS cost estimates

Calculate new AWS cost estimates with these resources:

  • 3x m3.medium ec2 servers to run SensorWebAPI, SensorThings API and Notifications Manager
    • this is a cluster so each server will run SensorWeb, SensorThings and a Notifications Manager
  • 1x t2.medium for Sensors Heartbeat Monitor
  • 1x t2.medium for admin console
  • 1x db.r3.large (multi-az) for the database server
  • 2x AWS ElasticLoadBalancers (for SensorThings and SensorWebAPI endpoints)

Session tokens must always contain clientId, userId (if any) and the list of allowed permissions

Right now we are generating two kind of session tokens:

  • For the admin user, with a payload like:
{
  "id": "admin",
  "scope": "admin"
}
  • For regular users, with a payload like:
{
  "id": {
    "opaqueId": "facebook_id",
    "provider": "facebook",
    "clientKey": "02e9c7"
  },
  "scope": "user"
}

Session tokens must always contain a client key, a list of allowed permissions, and may have or may not have a user associated. So we should end up with:

  • Anonymous session tokens:
{ 
  "clientId": "1234567890987654321",
  "scopes": ["sensorthings"]
}
  • User session tokens:
{
  "clientId": "1234567890987654321",
  "userId": {
    "opaqueId": "facebook_id",
    "idp": "facebook"
  },
  "scopes": ["sensorthings"]
}

The list of permissions is tbd in #53

Tests simplification: use promises, generators and template strings

In many tests (eg test_auth_api.js) we have:

  • string concatenation
  • callback-based tests (with mocha's done)
  • asynchronous code using promises or (worse !) callbacks

We can make them more readable using (respectively) template strings, promises and generators (using co-mocha).

User favorites API

We need an API to fulfill the following user stories:

  • As a user, I want to track multiple locations where I want to keep track of air quality so that I am on top of things without repeating the same search each time.
  • As a user I should be able to save a sensor to my favorites so that it will appear on a favorite view with labels so that I can see them easily
  • As a user I should be able to rename a favorite sensor
  • As a user I should be able to stop tracking a sensor as a favorite location.

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.