Skip to content

NLeSC/spot-server

Repository files navigation

spot-server

Build Status Codacy Badge Codacy Badge js-semistandard-style

Part of the spot-framework, spot-server provides a connection a to a database (currently PostgreSQL) instead of the default crossfilter backend. It will also host a static website fi. spot using Express.

API documenation can be found here.

prerequisites

Spot requires either a local or a remote service to run. Commutication between the client and the database server is achieved by using web socket. Before running the scripts, make sure that the Postgres server is up and running.

  • Hint: You may want to use PostreSQL Docker image for quick testing, if you don't have postgress installed on your system
  • make sure your postgres user does not need a password
  • pg_isready command might be useful to check the server status.

scripts

spot-server

Combines this library with Express to host a website. It uses a session file to keep track of database tables to serve.

Usage:

node scripts/spot-server.js -c 'postgres://USER@localhost/DATABASE' -s 'session_file.json' -w <SPOT_DIST>

Here, SPOT_DIST should be an absolute path to the directory with the built version of spot app. You can either use the pre-built dist directory or build it yourself using npm run dist.

run following command to see available options:

node scripts/spot-server.js --help

You can get a bit more performance using the native PostgreSQL bindings (turned off by default to make travisCI easier). Just install the pg-native package:

npm install pg-native

This in only tested on linux, could work on other OSs.

spot-import

Import files (CSV, JSON) into the database. It also creates a session file. Usage:

node ./scripts/spot-import.js -c 'postgres://USER@localhost/DATABASE' \
-t 'data_table' \
-s 'session_file.json' \
-u 'http://DATA_URL' \
-d 'Dataset description' \
--csv -f 'test_data.csv'

run following command to see available options:

node server/spot-import.js --help

Notes

heap out of memory

If node crashes with heap out of memory, increase it using node --max_old_space_size=4096.

Security concerns

sql injection via facet.accessor and dataset.datasetTable

Facet accessor can be set by the client, and is used unchecked in the query. Recommended to limit spot-server PostgreSQL privilege to read only. See for instance this blog post