Skip to content
This repository has been archived by the owner on Jan 15, 2020. It is now read-only.
/ nearby-services-api Public archive

DEPRECATED - no longer actively maintained

License

Notifications You must be signed in to change notification settings

nhsuk/nearby-services-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DEPRECATED - no longer actively maintained


Nearby services API

GitHub Release Greenkeeper badge Build Status Coverage Status

An API focusing on services near to a specific search point.

Currently, it is used by connecting-to-services to provide services near to a lat/lon.

This app uses nhsuk/bunyan-logger. As such, a number of environment variables can be used, and in production, NEED to be set for the logging to work. Check out the README in that repo for additional information.

API Interface

There are two endpoints available:

  • /open?latitude=$latitude&longitude=$longitude[&limits:results=$numberResults]
  • /nearby?latitude=$latitude&longitude=$longitude[&limits:results=$numberResults]

All query string parameters are validated and return an informative message when incorrect.

Mandatory query string parameters:

  • latitude - must be a valid latitude
  • longitude - must be a valid longitude

Optional query string parameters:

  • limits:results - the default and limits are defined in the config

Both endpoints return an object containing an array of pharmacies against a field called results e.g.

{
  results: [
  {
   ...
  },
  {
   ...
  }
  ]
}

Environment variables

Environment variables are expected to be managed by the environment in which the application is being run. This is best practice as described by twelve-factor.

For any env var that is required by the application to run and doesn't have a default require-environment-variables is used to throw an error and prevent the application from starting up. Rather than it getting to point somewhere later in the life cycle where it can't do something because there is no value for an env var it was relying on.

Variable Description Default
NODE_ENV Node environment development
LOG_LEVEL Numeric log level Depends on NODE_ENV
PORT Server port 3001
ES_INDEX Name of index in the ElasticSearch image pharmacies
ES_HOST Name of ElasticSearch host es
ES_PORT The port used by ElasticSearch 27017
RESULT_LIMIT_OPEN_MAX The maximum number of open results 10
RESULT_LIMIT_NEARBY_MAX The maximum number of nearby results 10

Running the application

Start by cloning the repo and all submodules i.e. git clone https://github.com/nhsuk/nearby-services-api.git && cd profiles/ && git submodule update --init --recursive

Next, have a look at the scripts for getting the application running scripts

Then click here to see results (if all went well).

To run the full stack application including the front end use the docker-compose-full-stack.yml, i.e. docker-compose -f docker-compose-full-stack.yml down -v docker-compose -f docker-compose-full-stack.yml up --build --force-recreate

Changing the time

This stack supports an environment variable to change the current time in the API. Sample format to set: export DATETIME=2017-02-15T03:30:00 And to remove: unset DATETIME

FAQ

  1. When I run docker-compose I get errors about packages missing. Often it seems to be Nodemon.
  • This could well be because the volume used by the service has previously been mounted when NODE_ENV was set to production. Try running docker-compose down -v which removes all the things created by the docker-compose up command, including volumes (with the -v flag). For test, run docker-compose -f docker-compose-tests.yml down -v

Contributing to the application

Make your changes but before you commit them run the tests.

Architecture Decision Records

This repo uses Architecture Decision Records to record architectural decisions for this project. They are stored in doc/adr.