Commit Graph

45 Commits

Author SHA1 Message Date
D. Berge
433daca9ef Add deep properties getter utility function to config.
cfg._("a.deep.property") returns the value of
cfg.a.deep.property if it exists. If the property
or any of its parents do not exist, returns undefined.
2020-08-31 13:07:27 +02:00
D. Berge
e5bc5a0757 Refactor project summaries to use database views 2020-08-26 20:20:53 +02:00
D. Berge
cb4846c900 Refactor project DB routines 2020-08-26 17:41:40 +02:00
D. Berge
c7c8f5df8a Sort sequence list by sequence descending by default 2020-08-25 18:31:51 +02:00
D. Berge
438f050c2a Add possibility to return associated files if requested.
Pass a trueish value in opts.files to get the list of
raw and final files associated with a sequence. It does
make the query about 30% slower as it stands.
2020-08-25 18:02:28 +02:00
D. Berge
00f1ea20da Allow sequences to be filtered.
Sequences can be filtered by:
* sequence number;
* line number;
* start / end date (of raw acquisition);
* remarks (raw or final).
2020-08-25 12:59:40 +02:00
D. Berge
f486b4835e Instrument alerts for HTTP backend.
An alert is sent whenever an endpoint returns
an error other than an explicit failure (e.g.,
it won't send an alert if a middleware intentionally
returns a {status: XXX} object).
2020-08-25 11:32:13 +02:00
D. Berge
650ed998c6 Read also global config in server backend.
The configuration file etc/config.yaml is exposed to the
server backend under require('configuration').global.

Note that at some point it will probably make sense to
merge the two config files.
2020-08-25 08:48:10 +02:00
D. Berge
9fa76df446 Be explicit about the encoding of JSON config 2020-08-25 08:47:04 +02:00
D. Berge
721dae4084 Catch all middleware errors 2020-08-24 13:25:14 +02:00
D. Berge
949defd2f6 Add event API endpoints 2020-08-22 20:46:15 +02:00
D. Berge
a55046ed93 Add a meta property to requests.
Using the meta(key, value) middleware factory, the user
can add a property req.meta[key] = value to the request.
2020-08-22 20:46:15 +02:00
D. Berge
0c4d91c603 Implement event DELETE middleware 2020-08-22 20:46:15 +02:00
D. Berge
5349708fb8 Implement event PUT middleware 2020-08-22 20:46:15 +02:00
D. Berge
58694ac1c1 Refactor event POST middleware.
It can now take some parameters from the request URL.
If present, request URL parameters take precedence over
request body values.
2020-08-22 20:45:59 +02:00
D. Berge
ba160c441c Implement db.event.del (delete) 2020-08-22 20:26:03 +02:00
D. Berge
517291d5c9 Implement db.event.put 2020-08-22 20:24:55 +02:00
D. Berge
81e0c40790 Refactor db.event.post 2020-08-22 20:24:10 +02:00
D. Berge
9e1f93d43e Adapt db.events.list to latest schema 2020-08-22 20:23:28 +02:00
D. Berge
c93188a5a7 Add event POST middleware to API 2020-08-16 10:50:58 +02:00
D. Berge
608fd9d3cd Refactor DB interface to use setSurvey() 2020-08-16 10:46:54 +02:00
D. Berge
170312efd6 Remove dead code from DB interface 2020-08-16 10:44:04 +02:00
D. Berge
ecbe4d38ca Add setSurvey() utility function to DB interface.
It sets the current survey and optionally returns a
client connection to use in subsequent queries.
2020-08-16 10:16:08 +02:00
D. Berge
dc1e08b452 Add transaction utility functions to DB interface 2020-08-16 10:15:44 +02:00
D. Berge
2bfa340b52 Add API endpoint to retrieve survey configuration.
The endpoint /project/:project/configuration/:path(*)?
returns the contents of the survey configuration YAML
file for a given project.

To retrieve the full configuration:
 * /project/:project/configuration

To retrieve a specific subset (e.g., binning parameters):

 * /project/:project/configuration/binning

To retrieve a specific value (e.g., inline bin width):

 * /project/:project/configuration/binning/I_width
2020-08-16 10:06:43 +02:00
D. Berge
6fa39eb3c7 Autogenerate JWT secret if not in production mode 2020-08-12 15:13:53 +02:00
D. Berge
9453d14ee5 Make API config search path consistent with backend.
The API configuration now accepts the same DOUGAL_ROOT
environment variable as the backend and uses the same
path algorithm.
2020-08-12 15:11:54 +02:00
D. Berge
d66e3dd661 Prefer environment variables to connect to DB 2020-08-12 14:39:33 +02:00
D. Berge
a73376572b API: Add label querying endpoint.
Labels can be associated with events and can have
display properties such as a description and colour,
this is why we need an endpoint for the client to
retrieve them.
2020-08-12 11:41:28 +02:00
D. Berge
d52f8f8bc2 API: Add event querying endpoint.
Events may be filtered by sequence(s):
   …/event?sequence=1
   …/event?sequence=1;3;7

Events may be filtered by date:
   …/event?date0=1970-01-01

Events may be filtered by a date interval:
   …/event?date0=1970-01-01&date1=1980-01-01

Events may also be paginated.
2020-08-12 11:35:57 +02:00
D. Berge
91f6fc3763 Remove debugging statement 2020-08-11 20:21:19 +02:00
D. Berge
ab6298cd42 GIS raw: avoid returning nulls 2020-08-11 20:19:58 +02:00
D. Berge
f1b2671d90 Project summary: paginate results 2020-08-11 19:35:13 +02:00
D. Berge
09e05388ac Remove dead code 2020-08-11 19:34:55 +02:00
D. Berge
bf1d94b730 Project summary: return count of final (not raw) shots 2020-08-11 19:33:17 +02:00
D. Berge
7b14041ac0 Project summary: return count of source preplots only 2020-08-11 19:32:11 +02:00
D. Berge
099cf909c1 GIS raw: return “stalks” showing the positioning error 2020-08-11 17:11:40 +02:00
D. Berge
ba253eae8d GIS final: return multiple features.
Rather than a single massive FeatureCollection.
2020-08-11 17:10:05 +02:00
D. Berge
380d39dd62 Truncate sequence durations to second in the GIS calls 2020-08-11 16:02:34 +02:00
D. Berge
9fa2b92d36 Remove debugging statement 2020-08-11 15:41:34 +02:00
D. Berge
cc156ab563 Remove commented out code 2020-08-11 15:41:12 +02:00
D. Berge
c661a7849a Return full line summary info for raw lines GIS endpoint 2020-08-11 15:38:39 +02:00
D. Berge
40f25287cb Adapt API GIS functions to latest database schema 2020-08-10 23:02:58 +02:00
D. Berge
a766a4dc6c Let API run with default settings in dev mode.
If the configuration file is not found, either at its
default place ($HOME/etc/www/config.json) or wherever
indicated by the DOUGAL_API_CONFIG environment variable,
create a temporary default config and try to run with it.

On the other hand, if we are in production (NODE_ENV == production)
we exit with non-zero in the absence of a real configuration file.
2020-08-09 10:50:53 +02:00
D. Berge
4c5d29494c Initial commit 2020-08-08 23:59:13 +02:00