1.8.0 • Published 4 years ago
relay-rest v1.8.0
relay-rest
Provides a public-facing REST API to server to access back-office things.
Environment variables
For running TESTS:
PG_CONNECTION_STRING=postgres://postgres:postgres@localhost:5432/my_test_db
SECRET=Shhh!
AUDIENCE=IAmTheAudience!
For running against LIVE:
PG_CONNECTION_STRING=postgres://postgres:postgres@wm-vms-dwh-01.wmfs.net:5432/bi
SECRET=Shhh!
AUDIENCE=IAmTheAudience!
Starting
$ npm start
API
incidents-in-progress
Request:
GET /relay/v1/incidents-in-progress
Response:
Status: 200
{
"generated": "2017-04-15T19:00:36.709Z",
"summaryUrlPrefix": "http://apps.wmfs.net:8280/incident-viewer/playback/incident/{{:callTimeYear}}/{{:incidentNumber}}",
"incidentsInProgress": [
{
"visIncNum": "022930-15042017",
"incidentNumber": "22930",
"callTime": "2017-04-15T18:49:48.000Z",
"callTimeYear": 2017,
"incidentClassification": "SSC_GAS_LEAK_PROVISIONAL",
"incidentClassificationLabel": "Gas leak (Provisional)",
"style": "DEFAULT_INCIDENT",
"iconName": "big_unknown.png",
"smallIconName": "small_unknown.png",
"color": null,
"backgroundColor": null,
"locationLatitude": "52.4115304940521",
"locationLongitude": "-1.52283888613262",
"mobilisationCategory": "CAT1",
"mobilisationTargetSeconds": 300,
"locationPostcodeAreaLabel": "CV1 4DH",
"locationWardLabel": "Sherbourne",
"locationBorough": "Coventry Borough",
"firstOnSceneCallsign": "B031",
"firstOnSceneBrigadeLocation": "Coventry",
"firstOnSceneType": "PRL",
"firstOnSceneReactionSeconds": 86,
"firstOnSceneTravelSeconds": 147,
"firstOnSceneJourneyDistance": "1472.08",
"firstOnSceneAssignedDistanceFromHomeBrigadeLocation": "502.70",
"prlCount": 2,
"brvCount": 0,
"bsvCount": 0,
"officerCount": 0,
"otherCount": 0,
"sensitivity": "PROTECTED"
}
]
}
incident-summary
Request:
GET relay/v1/incident-summary?year=2017&number=22930
Param | Description |
---|---|
year | The year of the incident to find |
number | The number of the incident to find |
Response:
Status: 200
{
"generated": "2017-02-28T16:52:50.241Z",
"incident": {
"visIncNum": "022930-15042017",
"incidentNumber": "22930",
"callTime": "2017-04-15T18:49:48.000Z",
"callTimeYear": 2017,
"incidentClassification": "SSC_GAS_LEAK_PROVISIONAL",
"incidentClassificationLabel": "Gas leak (Provisional)",
"style": "DEFAULT_INCIDENT",
"iconName": "big_unknown.png",
"smallIconName": "small_unknown.png",
"color": null,
"backgroundColor": null,
"locationLatitude": "52.4115304940521",
"locationLongitude": "-1.52283888613262",
"mobilisationCategory": "CAT1",
"mobilisationTargetSeconds": 300,
"locationPostcodeAreaLabel": "CV1 4DH",
"locationWardLabel": "Sherbourne",
"locationBorough": "Coventry Borough",
"firstOnSceneCallsign": "B031",
"firstOnSceneBrigadeLocation": "Coventry",
"firstOnSceneType": "PRL",
"firstOnSceneReactionSeconds": 86,
"firstOnSceneTravelSeconds": 147,
"firstOnSceneJourneyDistance": "1472.08",
"firstOnSceneAssignedDistanceFromHomeBrigadeLocation": "502.70",
"prlCount": 2,
"brvCount": 0,
"bsvCount": 0,
"officerCount": 0,
"otherCount": 0,
"sensitivity": "PROTECTED"
}
}
nearest-available-vehicle
Request:
GET /relay/v1/nearest-available-vehicle?location=400000,300000
Yup, could be much more flexible, but purposefully locked-downn (for political reasons).
Param | Description |
---|---|
location | Defines the point to work from. Currently only supports x/y coordinates. |
Response:
Status: 200
{
"generated": "2017-02-28T16:52:50.241Z",
"vehicles": [
{
"callsign": "B014",
"distanceMetres": 1213,
"distanceSeconds": 130
}
]
}
fleet-status
Request:
GET /relay/v1/fleet-status
Response:
Status: 200
{
"generated": "2018-01-17T10:49:10.180Z",
"vehicles": [
{
"callsign": "A021",
"last_seen_time": "2018-01-17T10:30:44.000Z",
"callsign_status_label": "Maximised Response (Delayed 60 mins)",
"callsign_status_group_label": "Maximised Response",
"brigade_location": "Aston",
"callsign_type": "PRL",
"vis_inc_num": null,
"incident_number": null,
"incident_year": null,
"x": "398933",
"y": "288313",
"lat": 52.4927266972808,
"lon": -2.01714426046149
},
{
"callsign": "A025",
"last_seen_time": "2018-01-17T10:31:13.000Z",
"callsign_status_label": "Maximised Response (Delayed 60 mins)",
"callsign_status_group_label": "Maximised Response",
"brigade_location": "Aston",
"callsign_type": "BRV",
"vis_inc_num": null,
"incident_number": null,
"incident_year": null,
"x": "398966",
"y": "288335",
"lat": 52.4929245464181,
"lon": -2.01665830089078
}
]
}
incident history
Request:
GET /relay/v1/incident-history?uprn=xxxx
Response:
Status: 200
{
"lastQueried": "DATE",
"generated": "DATE",
"INCIDENTS": [
{
"date": "DATE_OF_INCIDENT",
"address": "ADDRESS_OF_PROPERTY",
"label": "LABEL_OF_INCIDENT",
"lat": "LATITUDE_OF_ADDRESS",
"lon": "LONGITUDE_OF_ADDRESS"
},
{
"date": "DATE_OF_INCIDENT",
"address": "ADDRESS_OF_PROPERTY",
"label": "LABEL_OF_INCIDENT",
"lat": "LATITUDE_OF_ADDRESS",
"lon": "LONGITUDE_OF_ADDRESS"
}
]
}
TODO
- Currently only as-the-crow-flies distances, and seconds is always 130
Tests
$ npm test