Code Monkey home page Code Monkey logo

phn-qol-server's Introduction

PHN Quality of Life Survey

Server component

This repo holds the server component for Primary Health Networks Quality of Life Survey. The server component has been abstracted out, and will be configured to run independently of the web front-end or any subsequent incarnation of the survey itself (regional versions of the survey, mobile apps, embedded IoT instances, etc.)

Technology stack

This is an Express application running on Node.js. RDMBS Postgres has been chosen for its performance, scalability and maturity.

The server is an implementation of REST, issuing JWT tokens for client registration and responding in JSON format. GET, POST and HEAD commands will be the primary interface for interacting with the server and subsequently manipulating data. HTTP response codes will bear a significance with every HTTP request and error massaging will be minimal.

There is no front-end for this server instance- please see the API documentation for usage details.

Data definition

Entity-Relationship Diagram

Assumptions have been made regarding the data collected during the device registration process and supplied by PHN for each provider.

Instances

This web application will be split across multiple instances, development, staging and master for deployment. Each of these instances has a separate endpoint and dataset, and synchronisation between instances will be managed using git branching.

Branch master master Heroku status Circle CI

The master branch is the production version of the web application, hosted on the main domain. Any commits to master which is then pushed to GitHub will trigger a Circle CI build. If the build passess successfully, then the changes will automatically be deployed to the production site.

Branch staging staging Heroku status Circle CI

The staging branch is used to manage changes that are ready for or pending preparation for deployment to the master branch. The deployment process for the staging branch is identical to that of the master branch (although deployment is sent to a different domain name).

Branch development development Heroku status Circle CI

The development (dev) branch is used to synchronise development and feature extensions between collaborators. At present, the dev repository is being used to effect Circle CI integration. It may or may not survive v1.0 but nonetheless is automated for continuous delivery during development.

Testing

As we're using CircleCI for continuous delivery (CD; aka continuous Integration (CI)), testing; and importantly: extensive testing, is a crucial feature of this webapp. The way CI has been set up, if a single test fails, the application will not be deployed to the server.

As an API server, most of the testing that is conducted can be automated and for that we use the Mocha testing framework, along with Chai assertion library and SuperTest. There are broadly three categories of testing that takes place: unit testing, integration testing and system testing.

Running tests

Please see the Environment Variables documentation for the environment variable requirements for test execution.

Once the environment has all the requisite environment variables, the following commands may be used to test the server:

  • npm test - Uses the existing environment variables.
  • npm run test-local - loads any environment variables configured in a ./.env.test-local file before continuing to run the same tests.

Unit Testing

Unit tests are arranged into their components within the unit/ directory. By definition, these tests should operate on individual components, treating them as a black box to observe their behaviour. For a given input, there will be an expeted output and most discrete tests will simply compare the actual output to an expected output for a corresponding input.

Typically the unit being tested will be a single JavaScript file (imported or required in), and all tests that apply to that file will be stored in a similarly-named file within the test/ directory. Please note, whilst the JavaScript files being tested may import their own libraries, a unit test suite for that file will only be concerned with the methods exported by the module, and not the libraries being used.

Integration testing

Integration tests can be found in the integration/ directory. They are similar to unit tests however observe the behaviours of systems where multiple files or libraries are coordinated to produce an output. Typically, this will be testing the Express.js server to see that a given HTTP request produces an expected response (either header information, body information or both).

System testing

A higher-level suite of tests exist in the system/ directory, responsible for verifying that the necessary parts of the system are online and working. An example of this may be confirmation of database connectivity, SQL script execution, etc.

License

Copyright (c) Patternworks 2016, All rights reserved. Unauthorised copying of this file, via any medium is strictly prohibited. Proprietary and confidential. Written by Kashi Samaraweera <[email protected]>.

phn-qol-server's People

Contributors

kashisau avatar callumflack avatar

Watchers

James Cloos 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.