Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions sandbox/Sandbox endpoints - localhost.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@

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

## Manifest pages

[Manifest Pages Root](http://localhost:9000/manifest/pages/)

[Manifest Pages - Page 1](http://localhost:9000/manifest/pages/?page=1)

[Manifest Pages - Page 2](http://localhost:9000/manifest/pages/?page=2)


## Conditions

[Conditions Root](http://localhost:9000/conditions/)
Expand Down
5 changes: 5 additions & 0 deletions sandbox/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ app.get('/_status', handlers.status)
// ******************************************************************
app.all('/', handlers.root)

// ******************************************************************
// ** Manifest pages
// ******************************************************************
app.all('/manifest/pages/', handlers.manifestPagesRoot)

// ******************************************************************
// ** Conditions pages
// ******************************************************************
Expand Down
45 changes: 45 additions & 0 deletions sandbox/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ const log = require('loglevel')
const errorResourceNotFoundResponse = require('./responses/error-resource-not-found.json')
const errorSandboxResponseNotFound = require('./responses/error-sandbox-response-not-found.json')

// Manifest pages - Responses
const manifestPagesRootNoParamsResponse = require('./responses/manifest-pages-root-no-params.json')
const manifestPagesRootPage1Response = require('./responses/manifest-pages-root-page-1.json')
const manifestPagesRootPage2Response = require('./responses/manifest-pages-root-page-2.json')

// Conditions - Responses
const conditionsRootNoParamsResponse = require('./responses/conditions-root-no-params.json')
const conditionsAcanthosisNigricansResponse = require('./responses/conditions-acanthosis-nigricans-no-params.json')
Expand Down Expand Up @@ -100,6 +105,45 @@ async function root(req, res, next) {
next()
}

// ******************************************************************
// ** Manifest pages
// ******************************************************************

// Live website URL
// https://www.nhs.uk/manifest/pages/
// This sandbox on localhost
// http://localhost:9000/manifest/pages/
// API on Azure API Management
// https://api.nhs.uk/manifest/pages/
// Wagtail (Python) Application (no auth key required)
// https://www.nhs.uk/content-api/manifest/pages/
// Apigee Sandbox environment (no auth key required)
// https://sandbox.api.service.nhs.uk/nhs-website-content/manifest/pages/
// Apigee Integration environment ('apikey' required in Header)
// https://int.api.service.nhs.uk/nhs-website-content/manifest/pages/
// Apigee Production environment ('apikey' required in Header)
// https://api.service.nhs.uk/nhs-website-content/manifest/pages/
async function manifestPagesRoot(req, res, next) {
let responseJson
if (req.query.page) {
if (req.query.page === '1') {
// http://localhost:9000/manifest/pages/?page=1
responseJson = manifestPagesRootPage1Response
} else if (req.query.page === '2') {
// http://localhost:9000/manifest/pages/?page=2
responseJson = manifestPagesRootPage2Response
} else {
responseJson = errorSandboxResponseNotFound
}
} else {
responseJson = manifestPagesRootNoParamsResponse
}
res.status(200).json(responseJson)

res.end()
next()
}

// ******************************************************************
// ** Conditions pages
// ******************************************************************
Expand Down Expand Up @@ -1012,6 +1056,7 @@ async function status(req, res, next) {

module.exports = {
root,
manifestPagesRoot,
conditionsAcanthosisNigricans,
conditionsAchalasia,
conditionsAcne,
Expand Down
11 changes: 11 additions & 0 deletions sandbox/responses/_curl-commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ curl -X GET 'https://api.service.nhs.uk/nhs-website-content/contraception/' -H '
curl -X GET 'https://api.service.nhs.uk/nhs-website-content/vaccinations/' -H 'apikey: Oq5LuCPc5X69KFlIw6P7TVYrrJHSceX8' >> ./responses/vaccinations-root-no-params.json


*****************************************************************************************************************
** Manifest pages **
*****************************************************************************************************************

curl -X GET 'https://api.service.nhs.uk/nhs-website-content/manifest/pages/' -H 'apikey: Oq5LuCPc5X69KFlIw6P7TVYrrJHSceX8' >> ./responses/manifest-pages-root-no-params.json

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

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


*****************************************************************************************************************
** Conditions pages **
*****************************************************************************************************************
Expand Down
Loading