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
28 changes: 25 additions & 3 deletions sandbox/Sandbox endpoints - localhost.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

[Conditions Root - Category: A & Genre: Condition](http://localhost:9000/conditions/?category=a&genre=condition)

[Conditions Root - Category: A & Genre: Guide](http://localhost:9000/conditions/?category=a&genre=guide)

[Conditions Root - Category: A & Genre: Hub](http://localhost:9000/conditions/?category=a&genre=hub)

[Conditions Root - Category: B](http://localhost:9000/conditions/?category=b)
Expand All @@ -33,7 +31,7 @@

[Conditions Root - Page: 2](http://localhost:9000/conditions/?page=2)

[Conditions Root - Page: 70](http://localhost:9000/conditions/?page=70)
[Conditions Root - Page: 29](http://localhost:9000/conditions/?page=29)

[Conditions Wildcard - Modules: false](http://localhost:9000/conditions/*?modules=false)

Expand Down Expand Up @@ -146,3 +144,27 @@
[Periods](http://localhost:9000/womens-health/periods/)

[Anaemia](http://localhost:9000/womens-health/anaemia/)

## Symptoms

[Symptoms Root](http://localhost:9000/symptoms/)

[Symptoms Root - Category: A](http://localhost:9000/symptoms/?category=a)

[Symptoms Root - Category: B](http://localhost:9000/symptoms/?category=b)

[Symptoms Root - Page: 1](http://localhost:9000/symptoms/?page=1)

[Symptoms Root - Page: 6](http://localhost:9000/symptoms/?page=6)

## Tests and treatments

[Tests and treatments Root](http://localhost:9000/tests-and-treatments/)

[Tests and treatments - Category: A](http://localhost:9000/tests-and-treatments/?category=a)

[Tests and treatments - Category: B](http://localhost:9000/tests-and-treatments/?category=b)

[Tests and treatments - Page: 1](http://localhost:9000/tests-and-treatments/?page=1)

[Tests and treatments - Page: 7](http://localhost:9000/tests-and-treatments/?page=7)
10 changes: 10 additions & 0 deletions sandbox/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,16 @@ app.all('/womens-health/', handlers.womensHealthRoot)
app.all('/womens-health/periods/', handlers.womensHealthPeriods)
app.all('/womens-health/anaemia/', handlers.womensHealthAnaemia)

// ******************************************************************
// ** Symptoms
// ******************************************************************
app.all('/symptoms/', handlers.symptomsRoot)

// ******************************************************************
// ** Tests and treatments
// ******************************************************************
app.all('/tests-and-treatments/', handlers.testsAndTreatmentsRoot)

app.use((req, res, next) => {
res.status(404).json(errorResourceNotFoundResponse)
})
Expand Down
128 changes: 120 additions & 8 deletions sandbox/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ const conditionsAcneModulesTrueResponse = require('./responses/conditions-acne-m
const conditionsAngiographyResponse = require('./responses/conditions-angiography-no-params.json')
const conditionsCancerResponse = require('./responses/conditions-cancer-no-params.json')
const conditionsRootCategoryAGenreConditionResponse = require('./responses/conditions-root-category-a-genre-condition.json')
const conditionsRootCategoryAGenreGuideResponse = require('./responses/conditions-root-category-a-genre-guide.json')
const conditionsRootCategoryAGenreHubResponse = require('./responses/conditions-root-category-a-genre-hub.json')
const conditionsRootCategoryAResponse = require('./responses/conditions-root-category-a.json')
const conditionsRootCategoryBResponse = require('./responses/conditions-root-category-b.json')
const conditionsRootCategoryZResponse = require('./responses/conditions-root-category-z.json')
const conditionsRootPage1Response = require('./responses/conditions-root-page-1.json')
const conditionsRootPage2Response = require('./responses/conditions-root-page-2.json')
const conditionsRootPage70Response = require('./responses/conditions-root-page-70.json')
const conditionsRootPage29Response = require('./responses/conditions-root-page-29.json')
const conditionsWildcardResponseNoParams = require('./responses/conditions-acne-no-params.json')
const conditionsWildcardModulesTrueResponse = require('./responses/conditions-acne-modules-true.json')
const conditionsZikaResponse = require('./responses/conditions-zika-no-params.json')
Expand Down Expand Up @@ -86,6 +85,20 @@ const womensHealthRootResponse = require('./responses/womens-health-root-no-para
const womensHealthPeriodsResponse = require('./responses/womens-health-periods-no-params.json')
const womensHealthAnaemiaResponse = require('./responses/womens-health-anaemia-no-params.json')

// Symptoms - Responses
const symptomsRootNoParamsResponse = require('./responses/symptoms-root-no-params.json')
const symptomsRootCategoryAResponse = require('./responses/symptoms-root-category-a.json')
const symptomsRootCategoryBResponse = require('./responses/symptoms-root-category-b.json')
const symptomsRootPage1Response = require('./responses/symptoms-root-page-1.json')
const symptomsRootPage6Response = require('./responses/symptoms-root-page-6.json')

// Tests and treatments - Responses
const testsAndTreatmentsRootNoParamsResponse = require('./responses/tests-and-treatments-root-no-params.json')
const testsAndTreatmentsRootCategoryAResponse = require('./responses/tests-and-treatments-root-category-a.json')
const testsAndTreatmentsRootCategoryBResponse = require('./responses/tests-and-treatments-root-category-b.json')
const testsAndTreatmentsRootPage1Response = require('./responses/tests-and-treatments-root-page-1.json')
const testsAndTreatmentsRootPage7Response = require('./responses/tests-and-treatments-root-page-7.json')

// ******************************************************************
// ** Root page
// ******************************************************************
Expand Down Expand Up @@ -173,9 +186,6 @@ async function conditionsRoot(req, res, next) {
if (req.query.category.toLowerCase() === 'a' && req.query.genre.toLowerCase() === 'condition') {
// http://localhost:9000/conditions/?category=a&genre=condition
responseJson = conditionsRootCategoryAGenreConditionResponse
} else if (req.query.category.toLowerCase() === 'a' && req.query.genre.toLowerCase() === 'guide') {
// http://localhost:9000/conditions/?category=a&genre=guide
responseJson = conditionsRootCategoryAGenreGuideResponse
} else if (req.query.category.toLowerCase() === 'a' && req.query.genre.toLowerCase() === 'hub') {
// http://localhost:9000/conditions/?category=a&genre=hub
responseJson = conditionsRootCategoryAGenreHubResponse
Expand All @@ -202,9 +212,9 @@ async function conditionsRoot(req, res, next) {
} else if (req.query.page === '2') {
// http://localhost:9000/conditions/?page=2
responseJson = conditionsRootPage2Response
} else if (req.query.page === '70') {
// http://localhost:9000/conditions/?page=70
responseJson = conditionsRootPage70Response
} else if (req.query.page === '29') {
// http://localhost:9000/conditions/?page=29
responseJson = conditionsRootPage29Response
} else {
responseJson = errorSandboxResponseNotFound
}
Expand Down Expand Up @@ -1108,6 +1118,106 @@ async function womensHealthAnaemia(req, res, next) {
next()
}

// ******************************************************************
// ** Symptoms pages
// ******************************************************************

// Live website URL
// https://www.nhs.uk/symptoms/
// This sandbox on localhost
// http://localhost:9000/symptoms/
// API on Azure API Management
// https://api.nhs.uk/symptoms/
// Wagtail (Python) Application (no auth key required)
// https://www.nhs.uk/content-api/symptoms/
// Apigee Sandbox environment (no auth key required)
// https://sandbox.api.service.nhs.uk/nhs-website-content/symptoms/
// Apigee Integration environment ('apikey' required in Header)
// https://int.api.service.nhs.uk/nhs-website-content/symptoms/
// Apigee Production environment ('apikey' required in Header)
// https://api.service.nhs.uk/nhs-website-content/symptoms/
async function symptomsRoot(req, res, next) {
let responseJson
if (req.query.category) {
if (req.query.category.toLowerCase() === 'a') {
// http://localhost:9000/symptoms/?category=a
responseJson = symptomsRootCategoryAResponse
} else if (req.query.category.toLowerCase() === 'b') {
// http://localhost:9000/symptoms/?category=b
responseJson = symptomsRootCategoryBResponse
} else {
responseJson = errorSandboxResponseNotFound
}
} else if (req.query.page) {
if (req.query.page === '1') {
// http://localhost:9000/symptoms/?page=1
responseJson = symptomsRootPage1Response
} else if (req.query.page === '6') {
// http://localhost:9000/symptoms/?page=6
responseJson = symptomsRootPage6Response
} else {
responseJson = errorSandboxResponseNotFound
}
} else {
// http://localhost:9000/symptoms/
responseJson = symptomsRootNoParamsResponse
}
res.status(200).json(responseJson)

res.end()
next()
}

// ******************************************************************
// ** Tests and treatment pages
// ******************************************************************

// Live website URL
// https://www.nhs.uk/tests-and-treatments/
// This sandbox on localhost
// http://localhost:9000/tests-and-treatments/
// API on Azure API Management
// https://api.nhs.uk/tests-and-treatments/
// Wagtail (Python) Application (no auth key required)
// https://www.nhs.uk/content-api/tests-and-treatments/
// Apigee Sandbox environment (no auth key required)
// https://sandbox.api.service.nhs.uk/nhs-website-content/tests-and-treatments/
// Apigee Integration environment ('apikey' required in Header)
// https://int.api.service.nhs.uk/nhs-website-content/tests-and-treatments/
// Apigee Production environment ('apikey' required in Header)
// https://api.service.nhs.uk/nhs-website-content/tests-and-treatments/
async function testsAndTreatmentsRoot(req, res, next) {
let responseJson
if (req.query.category) {
if (req.query.category.toLowerCase() === 'a') {
// http://localhost:9000/tests-and-treatments/?category=a
responseJson = testsAndTreatmentsRootCategoryAResponse
} else if (req.query.category.toLowerCase() === 'b') {
// http://localhost:9000/tests-and-treatments/?category=b
responseJson = testsAndTreatmentsRootCategoryBResponse
} else {
responseJson = errorSandboxResponseNotFound
}
} else if (req.query.page) {
if (req.query.page === '1') {
// http://localhost:9000/tests-and-treatments/?page=1
responseJson = testsAndTreatmentsRootPage1Response
} else if (req.query.page === '7') {
// http://localhost:9000/tests-and-treatments/?page=7
responseJson = testsAndTreatmentsRootPage7Response
} else {
responseJson = errorSandboxResponseNotFound
}
} else {
// http://localhost:9000/tests-and-treatments/
responseJson = testsAndTreatmentsRootNoParamsResponse
}
res.status(200).json(responseJson)

res.end()
next()
}

// ******************************************************************
// ** Status
// ******************************************************************
Expand Down Expand Up @@ -1167,4 +1277,6 @@ module.exports = {
womensHealthAnaemia,
womensHealthPeriods,
womensHealthRoot,
symptomsRoot,
testsAndTreatmentsRoot,
}
Loading
Loading