Skip to content

Commit 82d096f

Browse files
committed
SYN-881 - add manifest pages to sandbox
1 parent 2f45c2f commit 82d096f

8 files changed

Lines changed: 6130 additions & 1 deletion

sandbox/Sandbox endpoints - localhost.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44

55
[API Root](http://localhost:9000/)
66

7+
## Manifest pages
8+
9+
[Manifest Pages Root](http://localhost:9000/manifest/pages/)
10+
11+
[Manifest Pages - Page 1](http://localhost:9000/manifest/pages/?page=1)
12+
13+
[Manifest Pages - Page 2](http://localhost:9000/manifest/pages/?page=2)
14+
15+
716
## Conditions
817

918
[Conditions Root](http://localhost:9000/conditions/)

sandbox/app.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ app.get('/_status', handlers.status)
131131
// ******************************************************************
132132
app.all('/', handlers.root)
133133

134+
// ******************************************************************
135+
// ** Manifest pages
136+
// ******************************************************************
137+
app.all('/manifest/pages/', handlers.manifestPagesRoot)
138+
134139
// ******************************************************************
135140
// ** Conditions pages
136141
// ******************************************************************

sandbox/handlers.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ const log = require('loglevel')
55
const errorResourceNotFoundResponse = require('./responses/error-resource-not-found.json')
66
const errorSandboxResponseNotFound = require('./responses/error-sandbox-response-not-found.json')
77

8+
// Manifest pages - Responses
9+
const manifestPagesRootNoParamsResponse = require('./responses/manifest-pages-root-no-params.json')
10+
const manifestPagesRootPage1Response = require('./responses/manifest-pages-root-page-1.json')
11+
const manifestPagesRootPage2Response = require('./responses/manifest-pages-root-page-2.json')
12+
813
// Conditions - Responses
914
const conditionsRootNoParamsResponse = require('./responses/conditions-root-no-params.json')
1015
const conditionsAcanthosisNigricansResponse = require('./responses/conditions-acanthosis-nigricans-no-params.json')
@@ -100,6 +105,45 @@ async function root(req, res, next) {
100105
next()
101106
}
102107

108+
// ******************************************************************
109+
// ** Manifest pages
110+
// ******************************************************************
111+
112+
// Live website URL
113+
// https://www.nhs.uk/manifest/pages/
114+
// This sandbox on localhost
115+
// http://localhost:9000/manifest/pages/
116+
// API on Azure API Management
117+
// https://api.nhs.uk/manifest/pages/
118+
// Wagtail (Python) Application (no auth key required)
119+
// https://www.nhs.uk/content-api/manifest/pages/
120+
// Apigee Sandbox environment (no auth key required)
121+
// https://sandbox.api.service.nhs.uk/nhs-website-content/manifest/pages/
122+
// Apigee Integration environment ('apikey' required in Header)
123+
// https://int.api.service.nhs.uk/nhs-website-content/manifest/pages/
124+
// Apigee Production environment ('apikey' required in Header)
125+
// https://api.service.nhs.uk/nhs-website-content/manifest/pages/
126+
async function manifestPagesRoot(req, res, next) {
127+
let responseJson
128+
if (req.query.page) {
129+
if (req.query.page === '1') {
130+
// http://localhost:9000/manifest/pages/?page=1
131+
responseJson = manifestPagesRootPage1Response
132+
} else if (req.query.page === '2') {
133+
// http://localhost:9000/manifest/pages/?page=2
134+
responseJson = manifestPagesRootPage2Response
135+
} else {
136+
responseJson = errorSandboxResponseNotFound
137+
}
138+
} else {
139+
responseJson = manifestPagesRootNoParamsResponse
140+
}
141+
res.status(200).json(responseJson)
142+
143+
res.end()
144+
next()
145+
}
146+
103147
// ******************************************************************
104148
// ** Conditions pages
105149
// ******************************************************************
@@ -1012,6 +1056,7 @@ async function status(req, res, next) {
10121056

10131057
module.exports = {
10141058
root,
1059+
manifestPagesRoot,
10151060
conditionsAcanthosisNigricans,
10161061
conditionsAchalasia,
10171062
conditionsAcne,

sandbox/responses/_curl-commands.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ curl -X GET 'https://api.service.nhs.uk/nhs-website-content/contraception/' -H '
1919
curl -X GET 'https://api.service.nhs.uk/nhs-website-content/vaccinations/' -H 'apikey: Oq5LuCPc5X69KFlIw6P7TVYrrJHSceX8' >> ./responses/vaccinations-root-no-params.json
2020

2121

22+
*****************************************************************************************************************
23+
** Manifest pages **
24+
*****************************************************************************************************************
25+
26+
curl -X GET 'https://api.service.nhs.uk/nhs-website-content/manifest/pages/' -H 'apikey: Oq5LuCPc5X69KFlIw6P7TVYrrJHSceX8' >> ./responses/manifest-pages-root-no-params.json
27+
28+
curl -X GET 'https://api.service.nhs.uk/nhs-website-content/manifest/pages/?page=1' -H 'apikey: Oq5LuCPc5X69KFlIw6P7TVYrrJHSceX8' >> ./responses/manifest-pages-root-page-1.json
29+
30+
curl -X GET 'https://api.service.nhs.uk/nhs-website-content/manifest/pages/?page=2' -H 'apikey: Oq5LuCPc5X69KFlIw6P7TVYrrJHSceX8' >> ./responses/manifest-pages-root-page-2.json
31+
32+
2233
*****************************************************************************************************************
2334
** Conditions pages **
2435
*****************************************************************************************************************

0 commit comments

Comments
 (0)