Skip to content

Commit a4145eb

Browse files
adrianparrigba1980
andauthored
Sandbox update (#46)
* Updated package.lock file * WIP * Init basic routes * Added more responses * Added more responses * Added more responses and formatted JSON * Added more responses * Added two more * Checking for ‘subscription-key’ * Catching 404 errors * Added more responses * Added Acne with modules=true * Tidy up * WIP * Added more endpoints * More endpoints * Fixed query params * More endpoints * Added a markdown file with localhost links * Added comments for Apigee Int and Prod environments * Adding in the ‘sandbox’ environment * Updated URLs * Added responses for wildcard examples --------- Co-authored-by: Igba ujege <iujege@gmail.com>
1 parent 9d67ed9 commit a4145eb

4 files changed

Lines changed: 1476 additions & 61 deletions

File tree

sandbox/Sandbox endpoints - localhost.md

Lines changed: 65 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,126 +2,136 @@
22

33
## API Root
44

5-
[API Root - Without subscription-key](http://localhost:9000/)
5+
[API Root - Without](http://localhost:9000/)
66

7-
[API Root - With example subscription-key](http://localhost:9000/?subscription-key=123456)
7+
[API Root - With example](http://localhost:9000/)
88

99
## Common Health Questions
1010

11-
[Common Health Questions Root - Without subscription-key](http://localhost:9000/common-health-questions/)
11+
[Common Health Questions Root - Without](http://localhost:9000/common-health-questions/)
1212

13-
[Common Health Questions Root - With example subscription-key](http://localhost:9000/common-health-questions/?subscription-key=123456)
13+
[Common Health Questions Root - With example](http://localhost:9000/common-health-questions/)
1414

15-
[Accidents, first aid and treatments](http://localhost:9000/common-health-questions/accidents-first-aid-and-treatments/?subscription-key=123456)
15+
[Accidents, first aid and treatments](http://localhost:9000/common-health-questions/accidents-first-aid-and-treatments/)
1616

17-
[Caring, carers and long-term conditions](http://localhost:9000/common-health-questions/caring-carers-and-long-term-conditions/?subscription-key=123456)
17+
[Caring, carers and long-term conditions](http://localhost:9000/common-health-questions/caring-carers-and-long-term-conditions/)
1818

19-
[Children's health - Can my baby go swimming before or after vaccinations?](http://localhost:9000/common-health-questions/childrens-health/can-my-baby-go-swimming-before-or-after-vaccinations/?subscription-key=123456)
19+
[Children's health - Can my baby go swimming before or after vaccinations?](http://localhost:9000/common-health-questions/childrens-health/can-my-baby-go-swimming-before-or-after-vaccinations/)
2020

2121
## Conditions
2222

23-
[Conditions Root - Without subscription-key](http://localhost:9000/conditions/)
23+
[Conditions Root - Without](http://localhost:9000/conditions/)
2424

25-
[Conditions Root - With example subscription-key](http://localhost:9000/conditions/?subscription-key=123456)
25+
[Conditions Root - With example](http://localhost:9000/conditions/)
2626

27-
[Conditions Root - Category: A](http://localhost:9000/conditions/?subscription-key=123456&category=a)
27+
[Conditions Root - Category: A](http://localhost:9000/conditions/?category=a)
2828

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

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

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

35-
[Conditions Root - Category: B](http://localhost:9000/conditions/?subscription-key=123456&category=b)
35+
[Conditions Root - Category: B](http://localhost:9000/conditions/?category=b)
3636

37-
[Conditions Root - Category: Z](http://localhost:9000/conditions/?subscription-key=123456&category=z)
37+
[Conditions Root - Category: Z](http://localhost:9000/conditions/?category=z)
3838

39-
[Conditions Root - Page: 1](http://localhost:9000/conditions/?subscription-key=123456&page=1)
39+
[Conditions Root - Page: 1](http://localhost:9000/conditions/?page=1)
4040

41-
[Conditions Root - Page: 2](http://localhost:9000/conditions/?subscription-key=123456&page=2)
41+
[Conditions Root - Page: 2](http://localhost:9000/conditions/?page=2)
4242

43-
[Conditions Root - Page: 70](http://localhost:9000/conditions/?subscription-key=123456&page=70)
43+
[Conditions Root - Page: 70](http://localhost:9000/conditions/?page=70)
4444

45-
[Acanthosis nigricans](http://localhost:9000/conditions/acanthosis-nigricans/?subscription-key=123456)
45+
[Conditions Wildcard - Modules: false](http://localhost:9000/conditions/*?modules=false)
4646

47-
[Achalasia](http://localhost:9000/conditions/achalasia/?subscription-key=123456)
47+
[Conditions Wildcard - Modules: true](http://localhost:9000/conditions/*?modules=true)
4848

49-
[Acne - Modules: false](http://localhost:9000/conditions/acne/?subscription-key=123456&modules=false)
49+
[Acanthosis nigricans](http://localhost:9000/conditions/acanthosis-nigricans/)
5050

51-
[Acne - Modules: true](http://localhost:9000/conditions/acne/?subscription-key=123456&modules=true)
51+
[Achalasia](http://localhost:9000/conditions/achalasia/)
5252

53-
[Angiography](http://localhost:9000/conditions/angiography/?subscription-key=123456)
53+
[Acne - Modules: false](http://localhost:9000/conditions/acne/?modules=false)
5454

55-
[Cancer](http://localhost:9000/conditions/cancer/?subscription-key=123456)
55+
[Acne - Modules: true](http://localhost:9000/conditions/acne/?modules=true)
5656

57-
[Zika](http://localhost:9000/conditions/zika/?subscription-key=123456)
57+
[Angiography](http://localhost:9000/conditions/angiography/)
58+
59+
[Cancer](http://localhost:9000/conditions/cancer/)
60+
61+
[Zika](http://localhost:9000/conditions/zika/)
5862

5963
## Live Well
6064

61-
[Live Well Root - Without subscription-key](http://localhost:9000/live-well/)
65+
[Live Well Root - Without](http://localhost:9000/live-well/)
6266

63-
[Live Well Root - With example subscription-key](http://localhost:9000/live-well/?subscription-key=123456)
67+
[Live Well Root - With example](http://localhost:9000/live-well/)
6468

65-
[Alcohol advice - Alcohol support](http://localhost:9000/live-well/alcohol-advice/alcohol-support/?subscription-key=123456)
69+
[Alcohol advice - Alcohol support](http://localhost:9000/live-well/alcohol-advice/alcohol-support/)
6670

67-
[Exercise](http://localhost:9000/live-well/exercise/?subscription-key=123456)
71+
[Exercise](http://localhost:9000/live-well/exercise/)
6872

69-
[Healthy weight](http://localhost:9000/live-well/healthy-weight/?subscription-key=123456)
73+
[Healthy weight](http://localhost:9000/live-well/healthy-weight/)
7074

7175
## Medicines
7276

73-
[Medicines Root - Without subscription-key](http://localhost:9000/medicines/)
77+
[Medicines Root - Without](http://localhost:9000/medicines/)
78+
79+
[Medicines Root - With example](http://localhost:9000/medicines/)
80+
81+
[Medicines Root - Category: A](http://localhost:9000/medicines/?category=a)
82+
83+
[Medicines Root - Category: B](http://localhost:9000/medicines/?category=b)
7484

75-
[Medicines Root - With example subscription-key](http://localhost:9000/medicines/?subscription-key=123456)
85+
[Medicines Root - Category: Z](http://localhost:9000/medicines/?category=z)
7686

77-
[Medicines Root - Category: A](http://localhost:9000/medicines/?subscription-key=123456&category=a)
87+
[Medicines Root - Page: 1](http://localhost:9000/medicines/?page=1)
7888

79-
[Medicines Root - Category: B](http://localhost:9000/medicines/?subscription-key=123456&category=b)
89+
[Medicines Root - Page: 11](http://localhost:9000/medicines/?page=11)
8090

81-
[Medicines Root - Category: Z](http://localhost:9000/medicines/?subscription-key=123456&category=z)
91+
[Medicines Wildcard - Modules: false](http://localhost:9000/medicines/*?modules=false)
8292

83-
[Medicines Root - Page: 1](http://localhost:9000/medicines/?subscription-key=123456&page=1)
93+
[Medicines Wildcard - Modules: true](http://localhost:9000/medicines/*?modules=true)
8494

85-
[Medicines Root - Page: 11](http://localhost:9000/medicines/?subscription-key=123456&page=11)
95+
[Aciclovir](http://localhost:9000/medicines/aciclovir/)
8696

87-
[Aciclovir](http://localhost:9000/medicines/aciclovir/?subscription-key=123456)
97+
[Acrivastine - Modules: false](http://localhost:9000/medicines/acrivastine/?modules=false)
8898

89-
[Acrivastine](http://localhost:9000/medicines/acrivastine/?subscription-key=123456)
99+
[Acrivastine - Modules: true](http://localhost:9000/medicines/acrivastine/?modules=true)
90100

91-
[Zopiclone](http://localhost:9000/medicines/zopiclone/?subscription-key=123456)
101+
[Zopiclone](http://localhost:9000/medicines/zopiclone/)
92102

93103
## Mental Health
94104

95-
[Mental Health Root - Without subscription-key](http://localhost:9000/mental-health/)
105+
[Mental Health Root - Without](http://localhost:9000/mental-health/)
96106

97-
[Mental Health Root - With example subscription-key](http://localhost:9000/mental-health/?subscription-key=123456)
107+
[Mental Health Root - With example](http://localhost:9000/mental-health/)
98108

99-
[Advice for life situations and events - Bullying at work](http://localhost:9000/mental-health/advice-for-life-situations-and-events/support-for-workplace-bullying/?subscription-key=123456)
109+
[Advice for life situations and events - Bullying at work](http://localhost:9000/mental-health/advice-for-life-situations-and-events/support-for-workplace-bullying/)
100110

101-
[Mental health conditions](http://localhost:9000/mental-health/conditions/?subscription-key=123456)
111+
[Mental health conditions](http://localhost:9000/mental-health/conditions/)
102112

103-
[Feelings, symptoms and behaviours](http://localhost:9000/mental-health/feelings-symptoms-behaviours/?subscription-key=123456)
113+
[Feelings, symptoms and behaviours](http://localhost:9000/mental-health/feelings-symptoms-behaviours/)
104114

105115
## NHS Services
106116

107-
[NHS Services Root - Without subscription-key](http://localhost:9000/nhs-services/)
117+
[NHS Services Root - Without](http://localhost:9000/nhs-services/)
108118

109-
[NHS Services Root - With example subscription-key](http://localhost:9000/nhs-services/?subscription-key=123456)
119+
[NHS Services Root - With example](http://localhost:9000/nhs-services/)
110120

111-
[GPs](http://localhost:9000/nhs-services/gps/?subscription-key=123456)
121+
[GPs](http://localhost:9000/nhs-services/gps/)
112122

113-
[GPs - How to register with a GP surgery](http://localhost:9000/nhs-services/gps/how-to-register-with-a-gp-surgery/?subscription-key=123456)
123+
[GPs - How to register with a GP surgery](http://localhost:9000/nhs-services/gps/how-to-register-with-a-gp-surgery/)
114124

115-
[Prescriptions and pharmacies](http://localhost:9000/nhs-services/prescriptions-and-pharmacies/?subscription-key=123456)
125+
[Prescriptions and pharmacies](http://localhost:9000/nhs-services/prescriptions-and-pharmacies/)
116126

117127
## Pregnancy
118128

119-
[Pregnancy Root - Without subscription-key](http://localhost:9000/pregnancy/)
129+
[Pregnancy Root - Without](http://localhost:9000/pregnancy/)
120130

121-
[Pregnancy Root - With example subscription-key](http://localhost:9000/pregnancy/?subscription-key=123456)
131+
[Pregnancy Root - With example](http://localhost:9000/pregnancy/)
122132

123-
[Finding out you're pregnant - Finding out you're pregnant](http://localhost:9000/pregnancy/finding-out/finding-out-you-are-pregnant/?subscription-key=123456)
133+
[Finding out you're pregnant - Finding out you're pregnant](http://localhost:9000/pregnancy/finding-out/finding-out-you-are-pregnant/)
124134

125-
[Having a baby if you're LGBT+](http://localhost:9000/pregnancy/having-a-baby-if-you-are-lgbt-plus/?subscription-key=123456)
135+
[Having a baby if you're LGBT+](http://localhost:9000/pregnancy/having-a-baby-if-you-are-lgbt-plus/)
126136

127-
[Trying for a baby](http://localhost:9000/pregnancy/trying-for-a-baby/?subscription-key=123456)
137+
[Trying for a baby](http://localhost:9000/pregnancy/trying-for-a-baby/)

sandbox/app.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ app.all(
153153
// ** Conditions pages
154154
// ******************************************************************
155155
app.all('/conditions/', handlers.conditionsRoot)
156+
app.all('/conditions/*', handlers.conditionsWildcard)
156157
app.all('/conditions/acanthosis-nigricans/', handlers.conditionsAcanthosisNigricans)
157158
app.all('/conditions/achalasia/', handlers.conditionsAchalasia)
158159
app.all('/conditions/acne/', handlers.conditionsAcne)
@@ -172,6 +173,7 @@ app.all('/live-well/healthy-weight/', handlers.liveWellHealthyWeight)
172173
// ** Medicines pages
173174
// ******************************************************************
174175
app.all('/medicines/', handlers.medicinesRoot)
176+
app.all('/medicines/*', handlers.medicinesWildcard)
175177
app.all('/medicines/aciclovir/', handlers.medicinesAciclovir)
176178
app.all('/medicines/acrivastine/', handlers.medicinesAcrivastine)
177179
app.all('/medicines/zopiclone/', handlers.medicinesZopiclone)

sandbox/handlers.js

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const commonHealthQuestionsChildrensHealthCanMyBabyGoSwimmingBeforeOrAfterVaccin
1313
const conditionsRootNoParamsResponse = require('./responses/conditions-root-no-params.json')
1414
const conditionsAcanthosisNigricansResponse = require('./responses/conditions-acanthosis-nigricans-no-params.json')
1515
const conditionsAchalasiaResponse = require('./responses/conditions-achalasia-no-params.json')
16-
const conditionsAcneResponseNoParams = require('./responses/conditions-acne-no-params.json')
16+
const conditionsAcneNoParamsResponse = require('./responses/conditions-acne-no-params.json')
1717
const conditionsAcneModulesTrueResponse = require('./responses/conditions-acne-modules-true.json')
1818
const conditionsAngiographyResponse = require('./responses/conditions-angiography-no-params.json')
1919
const conditionsCancerResponse = require('./responses/conditions-cancer-no-params.json')
@@ -26,6 +26,8 @@ const conditionsRootCategoryZResponse = require('./responses/conditions-root-cat
2626
const conditionsRootPage1Response = require('./responses/conditions-root-page-1.json')
2727
const conditionsRootPage2Response = require('./responses/conditions-root-page-2.json')
2828
const conditionsRootPage70Response = require('./responses/conditions-root-page-70.json')
29+
const conditionsWildcardResponseNoParams = require('./responses/conditions-acne-no-params.json')
30+
const conditionsWildcardModulesTrueResponse = require('./responses/conditions-acne-modules-true.json')
2931
const conditionsZikaResponse = require('./responses/conditions-zika-no-params.json')
3032

3133
const liveWellRootResponse = require('./responses/live-well-root-no-params.json')
@@ -35,12 +37,15 @@ const liveWellHealthyWeightResponse = require('./responses/live-well-healthy-wei
3537

3638
const medicinesRootNoParamsResponse = require('./responses/medicines-root-no-params.json')
3739
const medicinesAciclovirResponse = require('./responses/medicines-aciclovir-no-params.json')
38-
const medicinesAcrivastineResponse = require('./responses/medicines-acrivastine-no-params.json')
40+
const medicinesAcrivastineNoParamsResponse = require('./responses/medicines-acrivastine-no-params.json')
41+
const medicinesAcrivastineModulesTrueResponse = require('./responses/medicines-acrivastine-modules-true.json')
3942
const medicinesRootCategoryAResponse = require('./responses/medicines-root-category-a.json')
4043
const medicinesRootCategoryBResponse = require('./responses/medicines-root-category-b.json')
4144
const medicinesRootCategoryZResponse = require('./responses/medicines-root-category-z.json')
4245
const medicinesRootPage1Response = require('./responses/medicines-root-page-1.json')
4346
const medicinesRootPage11Response = require('./responses/medicines-root-page-11.json')
47+
const medicinesWildcardNoParamsResponse = require('./responses/medicines-acrivastine-no-params.json')
48+
const medicinesWildcardModulesTrueResponse = require('./responses/medicines-acrivastine-modules-true.json')
4449
const medicinesZopicloneResponse = require('./responses/medicines-zopiclone-no-params.json')
4550

4651
const mentalHealthRootResponse = require('./responses/mental-health-root-no-params.json')
@@ -279,7 +284,7 @@ async function conditionsAchalasia(req, res, next) {
279284

280285
// Modules: false
281286
// This sandbox on localhost
282-
// http://localhost:9000/conditions/acne/?modules=false&subscription-key=123456
287+
// http://localhost:9000/conditions/acne/?modules=false
283288
// API on Azure API Management
284289
// https://api.nhs.uk/conditions/acne/
285290
// Wagtail (Python) Application (no auth key required)
@@ -293,7 +298,7 @@ async function conditionsAchalasia(req, res, next) {
293298

294299
// Modules: true
295300
// This sandbox on localhost
296-
// http://localhost:9000/conditions/acne/?modules=true&subscription-key=123456
301+
// http://localhost:9000/conditions/acne/?modules=true
297302
// API on Azure API Management
298303
// https://api.nhs.uk/conditions/acne/?modules=true
299304
// Wagtail (Python) Application (no auth key required)
@@ -308,7 +313,24 @@ async function conditionsAcne(req, res, next) {
308313
if (req.query.modules.toLowerCase() === 'true') {
309314
res.status(200).json(conditionsAcneModulesTrueResponse)
310315
} else {
311-
res.status(200).json(conditionsAcneResponseNoParams)
316+
res.status(200).json(conditionsAcneNoParamsResponse)
317+
}
318+
res.end()
319+
next()
320+
}
321+
322+
// Modules: false
323+
// This sandbox on localhost
324+
// http://localhost:9000/conditions/*?modules=false
325+
326+
// Modules: true
327+
// This sandbox on localhost
328+
// http://localhost:9000/conditions/*?modules=true
329+
async function conditionsWildcard(req, res, next) {
330+
if (req.query.modules.toLowerCase() === 'true') {
331+
res.status(200).json(conditionsWildcardModulesTrueResponse)
332+
} else {
333+
res.status(200).json(conditionsWildcardResponseNoParams)
312334
}
313335
res.end()
314336
next()
@@ -533,6 +555,8 @@ async function medicinesAciclovir(req, res, next) {
533555

534556
// Live website URL
535557
// https://www.nhs.uk/medicines/acrivastine/
558+
559+
// Modules: false
536560
// This sandbox on localhost
537561
// http://localhost:9000/medicines/acrivastine/
538562
// API on Azure API Management
@@ -545,8 +569,43 @@ async function medicinesAciclovir(req, res, next) {
545569
// https://int.api.service.nhs.uk/nhs-website-content/medicines/acrivastine/
546570
// Apigee Production environment ('apikey' required in Header)
547571
// https://api.service.nhs.uk/nhs-website-content/medicines/acrivastine/
572+
573+
// Modules: true
574+
// This sandbox on localhost
575+
// http://localhost:9000/medicines/acrivastine/?modules=true
576+
// API on Azure API Management
577+
// https://api.nhs.uk/medicines/acrivastine/?modules=true
578+
// Wagtail (Python) Application (no auth key required)
579+
// https://api.nhs.uk/content-api/medicines/acrivastine/?modules=true
580+
// Apigee Sandbox environment (no auth key required)
581+
// https://sandbox.api.service.nhs.uk/nhs-website-content/medicines/acrivastine/?modules=true
582+
// Apigee Integration environment ('apikey' required in Header)
583+
// https://int.api.service.nhs.uk/nhs-website-content/medicines/acrivastine/?modules=true
584+
// Apigee Production environment ('apikey' required in Header)
585+
// https://api.service.nhs.uk/nhs-website-content/medicines/acrivastine/?modules=true
548586
async function medicinesAcrivastine(req, res, next) {
549-
res.status(200).json(medicinesAcrivastineResponse)
587+
if (req.query.modules.toLowerCase() === 'true') {
588+
res.status(200).json(medicinesAcrivastineModulesTrueResponse)
589+
} else {
590+
res.status(200).json(medicinesAcrivastineNoParamsResponse)
591+
}
592+
res.end()
593+
next()
594+
}
595+
596+
// Modules: false
597+
// This sandbox on localhost
598+
// http://localhost:9000/medicines/*?modules=false
599+
600+
// Modules: true
601+
// This sandbox on localhost
602+
// http://localhost:9000/medicines/*?modules=true
603+
async function medicinesWildcard(req, res, next) {
604+
if (req.query.modules.toLowerCase() === 'true') {
605+
res.status(200).json(medicinesWildcardModulesTrueResponse)
606+
} else {
607+
res.status(200).json(medicinesWildcardNoParamsResponse)
608+
}
550609
res.end()
551610
next()
552611
}
@@ -850,6 +909,7 @@ module.exports = {
850909
conditionsAngiography,
851910
conditionsCancer,
852911
conditionsRoot,
912+
conditionsWildcard,
853913
conditionsZika,
854914
liveWellAlcoholAdviceAlcoholSupport,
855915
liveWellExercise,
@@ -858,6 +918,7 @@ module.exports = {
858918
medicinesAciclovir,
859919
medicinesAcrivastine,
860920
medicinesRoot,
921+
medicinesWildcard,
861922
medicinesZopiclone,
862923
mentalHealthAdviceForLifeSituationsAndEventsSupportForWorkplaceBullying,
863924
mentalHealthConditions,

0 commit comments

Comments
 (0)