Data service for Observe platform. This is a web server built in Node.js that provides an application programming interface for the dashboard and mobile app of Observe.
Documentation is available at:
This software is in early stages of development. Please visit the issues page to learn about known bugs and feature development.
To set up a development environment, install the following on your system:
Clone this repository locally and activate target Node.js version:
nvm install
Install Node.js dependencies:
npm install
There are two ways of passing application options for PostgreSQL and OAuth:
-
Using environment variables, full list available at config/custom-environment-variables.json
-
Adding configuration file
config/local-development.json
. It will not be git-tracked and will override options fordevelopment
environment. Please refer to this example.
This application uses config module, please check the documentation for usage details.
Start development database:
npm run start-dev-db
Open a new terminal and migrate the database:
npm run migrate-dev-db
Add mock users, traces and photos for testing:
npm run seed-dev
Start development server with changes monitoring:
npm run dev
Access the service at localhost:3000
When finished, go back to the first terminal session and kill the database container with Ctrl+C.
Start test database:
npm run start-test-db
There is no need to migrate the test database, it will be reset on every test run.
Open a new terminal and run tests:
npm run test
When finished, go back to the first terminal session and kill the database container with Ctrl+C.
A script is available to list files in the media folder that do not correspond to a existing photo at the database. The example command below will connect to the test database and generate a list of "orphaned" media files to orphaned.txt
, which can be used to remove files via shell script:
NODE_ENV=test node -r esm scripts/list-orphaned-files > orphaned.txt
Change or remove NODE_ENV
value to apply to a different environment.
Start documentation server:
npm run view-docs
Visit http://localhost:8080.