GithubHelp home page GithubHelp logo

isabella232 / wdfn-graph-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from usgs/wdfn-graph-server

0.0 0.0 0.0 1.26 MB

Water Data For the Nation Image Server

Home Page: https://labs.waterdata.usgs.gov/api/graph-images/api-docs/

License: Other

JavaScript 93.95% Dockerfile 6.05%

wdfn-graph-server's Introduction

WDFN Server-side Graph Renderer

Build Status codecov

This project provides a node.js server-side rendering agent for Water Data For The Nation graphs.

API

OpenAPI documentation for endpoints

/api-docs

Status service

/status Returns json object containing the version of the running service

Monitoring Location service

/monitoring-location/\<siteid\>/?parameterCode=xxxxx Returns a png containing a hydrograph for parameterCode(xxxxxx) for the NWIS site(siteid) for the last seven days. The query parameter parameterCode is required and should be a valid NWIS parameter code (see https://help.waterdata.usgs.gov/parameter_cd?group_cd=%)

Optional query parameters

See the OpenAPI documentation for the current list of available list of query parameters

Running the server for development

IMPORTANT! You will need version 14.1.0 or higher of Node.js.

Lower versions of Node will not unzip the internal Chromium package correctly and this will cause the graph server to 'hang' while it attempts to access a file that it will never find.

The dependencies need to be installed. To clear out any existing dependencies and to install:

% npm run clean
% npm install

The default port will be 2929 and the base of the URL will start with api/graph-images.

Example - local URL base
localhost:2929/api/graph-images/

Example - a query that will return a graph for 'depth to water level, feet below land surface' at USGS monitoring location 354133082042203
http://localhost:2929/api/graph-images/monitoring-location/354133082042203/?parameterCode=72019

Swagger

Swagger is a application that programmatically generates documentation. Using the generated documentation, you can create various URLs which can be used to test the application or generate graphs.

Example - local URL for Swagger Documentation
http://localhost:2929/api/graph-images/api-docs

The swagger json needs to be generated prior to running. If one of the convenience commands below are used, the swagger json file is generated before the express server starts. If you want to build separately the command is:

% npm run build:swagger

The entrypoint for the application is src/index.js, which accepts the following environment variables as arguments:

For example:

% NODE_PORT=80 node src/index.js

Convenience scripts for running the server for local development

To run a server locally with debug set for express and using default environment variables

% npm run start

If you would like the server to automatically reload on code changes:

% npm run watch

Running tests

Tests can be run by using the command:

% npm run test

By default this will expect the assets to be loaded at localhost:9000 for the images. Typically this means that you should also be running the asset server for waterdataui.

To run the tests in watch mode use:

% npm run test:watch

Miscellaneous scripts

You can run eslint against your javascript code using

% npm run lint

Docker

For deployment, a docker image is built and then deployed. To mimic the same thing locally execute the following from the root level of this repo (note: by default, the Docker container uses the same port as the local server, so shut down the local version before running):

% docker build -t wdfn_graph_server ./
% docker run -p 2929:2929 --privileged wdfn_graph_server

wdfn-graph-server's People

Contributors

abriggs-usgs avatar dependabot-preview[bot] avatar dependabot[bot] avatar kkehl-usgs avatar mbucknell avatar ssoper-usgs avatar

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.