hof 21.0.1-axios-beta → 21.0.1-beta-payload-too-large

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. package/.nyc_output/1e54a5ac-ed7a-4c0d-9b5f-5675cd8a7d41.json +1 -0
  2. package/.nyc_output/processinfo/1e54a5ac-ed7a-4c0d-9b5f-5675cd8a7d41.json +1 -0
  3. package/.nyc_output/processinfo/index.json +1 -1
  4. package/CHANGELOG.md +16 -0
  5. package/codeReviewChecklist.md +22 -0
  6. package/config/hof-defaults.js +8 -0
  7. package/frontend/govuk-template/build/govuk_template.html +20 -22
  8. package/frontend/govuk-template/govuk_template_generated.html +102 -0
  9. package/frontend/template-mixins/mixins/template-mixins.js +1 -0
  10. package/frontend/template-mixins/partials/forms/checkbox.html +5 -0
  11. package/frontend/template-mixins/partials/forms/input-text-group.html +1 -1
  12. package/frontend/template-mixins/partials/forms/select.html +6 -6
  13. package/frontend/template-mixins/partials/forms/textarea-group.html +4 -4
  14. package/frontend/template-partials/views/partials/gatag.html +0 -1
  15. package/frontend/template-partials/views/partials/head.html +23 -0
  16. package/lib/ga-tag.js +33 -7
  17. package/lib/settings.js +3 -2
  18. package/middleware/cookies.js +2 -0
  19. package/model/apis/html-to-pdf-converter.js +8 -9
  20. package/model/index.js +28 -27
  21. package/package.json +8 -9
  22. package/pull_request.md +16 -0
  23. package/sandbox/apps/sandbox/translations/en/default.json +26 -30
  24. package/sandbox/package.json +1 -1
  25. package/sandbox/public/css/app.css +6614 -10
  26. package/sandbox/public/js/bundle.js +2800 -24
  27. package/sandbox/yarn.lock +14 -9
  28. package/.nyc_output/4fc007c9-d6c8-4614-89ce-04c7d6ce9fe5.json +0 -1
  29. package/.nyc_output/processinfo/4fc007c9-d6c8-4614-89ce-04c7d6ce9fe5.json +0 -1
@@ -17,18 +17,17 @@ module.exports = class PDFModel extends Model {
17
17
  }
18
18
 
19
19
  handleResponse(response, callback) {
20
- if (isPdf(Buffer.from(response.data))) {
21
- return this.parseResponse(response.status, response.data, callback);
20
+ if (isPdf(Buffer.from(response.body))) {
21
+ return this.parseResponse(response.statusCode, response.body, callback);
22
22
  }
23
23
  const err = new Error();
24
-
25
- if (parseInt(response.status, 10) === 400) {
26
- err.title = response.status;
27
- err.message = response.statusText;
24
+ if (parseInt(response.statusCode, 10) === 400) {
25
+ err.title = response.body.code;
26
+ err.message = response.body.message;
28
27
  } else {
29
- err.body = response.data;
28
+ err.body = response.body;
30
29
  }
31
- err.status = response.status;
32
- return callback(err, null, response.status);
30
+ err.status = response.statusCode;
31
+ return callback(err, null, response.statusCode);
33
32
  }
34
33
  };
package/model/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  'use strict';
3
3
 
4
4
  const _ = require('lodash');
5
- const axios = require('axios').default;
5
+ const request = require('request');
6
6
  const url = require('url');
7
7
  const EventEmitter = require('events').EventEmitter;
8
8
 
@@ -27,7 +27,7 @@ module.exports = class Model extends EventEmitter {
27
27
  this.set(attributes, {
28
28
  silent: true
29
29
  });
30
- this._request = axios;
30
+ this._request = request;
31
31
  }
32
32
 
33
33
  save(options, callback) {
@@ -47,6 +47,7 @@ module.exports = class Model extends EventEmitter {
47
47
  'Content-Type': 'application/json',
48
48
  'Content-Length': Buffer.byteLength(data)
49
49
  }, reqConf.headers || {});
50
+
50
51
  return this.request(reqConf, data, callback);
51
52
  });
52
53
  }
@@ -90,26 +91,25 @@ module.exports = class Model extends EventEmitter {
90
91
  callback = body;
91
92
  body = undefined;
92
93
  }
94
+
93
95
  let settings = Object.assign({}, originalSettings);
94
96
  settings.timeout = settings.timeout || this.options.timeout;
95
- settings.url = settings.uri || settings.url || url.format(settings);
96
- settings.data = settings.body || body || settings.data;
97
- settings = _.omit(settings, urlKeys);
97
+ settings.uri = settings.uri || settings.url || url.format(settings);
98
+ settings.body = settings.body || body || settings.data;
99
+
100
+ settings = _.omit(settings, urlKeys, 'data', 'url');
98
101
  this.emit('sync', originalSettings);
99
102
 
100
103
  const promise = Promise.resolve().then(() => this.auth()).then(authData => {
101
- let authVal = authData;
102
- if (typeof authVal === 'string') {
103
- const auth = authVal.split(':');
104
- authVal = {
104
+ settings.auth = authData;
105
+ if (typeof settings.auth === 'string') {
106
+ const auth = settings.auth.split(':');
107
+ settings.auth = {
105
108
  user: auth.shift(),
106
109
  pass: auth.join(':'),
107
110
  sendImmediately: true
108
111
  };
109
112
  }
110
- if(authVal) {
111
- settings.headers = Object.assign({}, settings.headers, {Authorization: `Bearer ${authVal.bearer}`});
112
- }
113
113
  })
114
114
  .then(() => {
115
115
  const startTime = process.hrtime();
@@ -124,6 +124,7 @@ module.exports = class Model extends EventEmitter {
124
124
 
125
125
  const endTime = process.hrtime();
126
126
  const responseTime = timeDiff(startTime, endTime);
127
+
127
128
  if (err) {
128
129
  this.emit('fail', err, data, originalSettings, statusCode, responseTime);
129
130
  } else {
@@ -136,22 +137,22 @@ module.exports = class Model extends EventEmitter {
136
137
  }
137
138
  };
138
139
 
139
- this._request(settings)
140
- .then(response => {
141
- return this.handleResponse(response, (error, data, status) => {
142
- if (error) {
143
- error.headers = response.headers;
144
- }
145
- _callback(error, data, status);
146
- });
147
- }).catch(err => {
140
+ this._request(settings, (err, response) => {
141
+ if (err) {
148
142
  if (err.code === 'ETIMEDOUT' || err.code === 'ESOCKETTIMEDOUT') {
149
143
  err.message = 'Connection timed out';
150
144
  err.status = 504;
151
145
  }
152
- err.status = err.status || 503;
146
+ err.status = err.status || (response && response.statusCode) || 503;
153
147
  return _callback(err, null, err.status);
148
+ }
149
+ return this.handleResponse(response, (error, data, status) => {
150
+ if (error) {
151
+ error.headers = response.headers;
152
+ }
153
+ _callback(error, data, status);
154
154
  });
155
+ });
155
156
  });
156
157
  });
157
158
 
@@ -164,13 +165,13 @@ module.exports = class Model extends EventEmitter {
164
165
  handleResponse(response, callback) {
165
166
  let data = {};
166
167
  try {
167
- data = typeof response.data === 'object' ? response.data : JSON.parse(response.data || '{}');
168
+ data = JSON.parse(response.body || '{}');
168
169
  } catch (err) {
169
- err.status = response.status;
170
- err.body = response.data;
171
- return callback(err, null, response.status);
170
+ err.status = response.statusCode;
171
+ err.body = response.body;
172
+ return callback(err, null, response.statusCode);
172
173
  }
173
- return this.parseResponse(response.status, data, callback);
174
+ return this.parseResponse(response.statusCode, data, callback);
174
175
  }
175
176
 
176
177
  parseResponse(statusCode, data, callback) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hof",
3
3
  "description": "A bootstrap for HOF projects",
4
- "version": "21.0.1-axios-beta",
4
+ "version": "21.0.1-beta-payload-too-large",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
7
7
  "author": "HomeOffice",
@@ -32,12 +32,10 @@
32
32
  "test:acceptance_browser": "ACCEPTANCE_WITH_BROWSER=true TAGS=\"${TAGS:=@feature}\" yarn run test:cucumber",
33
33
  "test:cucumber": "cucumber-js -f @cucumber/pretty-formatter \"sandbox/test/_features/**/*.feature\" --require sandbox/test/_features/test.setup.js --require \"sandbox/test/_features/step_definitions/**/*.js\" --tags $TAGS",
34
34
  "ci": "travis-conditions",
35
- "postversion": "git push && git push --tags",
36
- "test-single":"mocha"
35
+ "postversion": "git push && git push --tags"
37
36
  },
38
37
  "dependencies": {
39
38
  "aliasify": "^2.1.0",
40
- "axios": "^1.5.1",
41
39
  "bluebird": "^3.7.2",
42
40
  "body-parser": "^1.15.1",
43
41
  "browserify": "^17.0.0",
@@ -59,7 +57,7 @@
59
57
  "findup": "^0.1.5",
60
58
  "glob": "^7.2.0",
61
59
  "govuk-elements-sass": "^3.1.3",
62
- "govuk-frontend": "3.14",
60
+ "govuk-frontend": "3.15",
63
61
  "govuk_template_mustache": "^0.26.0",
64
62
  "helmet": "^3.22.0",
65
63
  "hogan-express-strict": "^0.5.4",
@@ -68,7 +66,7 @@
68
66
  "i18n-future": "^2.0.0",
69
67
  "i18n-lookup": "^0.1.0",
70
68
  "is-pdf": "^1.0.0",
71
- "libphonenumber-js": "^1.9.37",
69
+ "libphonenumber-js": "^1.9.44",
72
70
  "lodash": "^4.17.21",
73
71
  "markdown-it": "^12.3.2",
74
72
  "minimatch": "^3.0.7",
@@ -84,6 +82,7 @@
84
82
  "notifications-node-client": "^6.0.0",
85
83
  "redis": "^3.1.2",
86
84
  "reqres": "^3.0.1",
85
+ "request": "^2.79.0",
87
86
  "rimraf": "^3.0.2",
88
87
  "sass": "^1.56.2",
89
88
  "serve-static": "^1.14.1",
@@ -97,6 +96,7 @@
97
96
  "@cucumber/cucumber": "^7.3.0",
98
97
  "@cucumber/pretty-formatter": "^1.0.0-alpha.1",
99
98
  "@types/jest": "^26.0.14",
99
+ "@xmldom/xmldom": "~0.8.4",
100
100
  "chai": "^3.5.0",
101
101
  "chai-as-promised": "^7.1.1",
102
102
  "chai-subset": "^1.6.0",
@@ -123,14 +123,13 @@
123
123
  "playwright": "^1.16.3",
124
124
  "postcode": "0.2.2",
125
125
  "proxyquire": "^1.7.11",
126
- "release-it": "^14.10.0",
126
+ "release-it": "^16.2.1",
127
127
  "sinon": "^11.1.1",
128
128
  "sinon-chai": "^3.7.0",
129
129
  "supertest": "^3.0.0",
130
130
  "travis-conditions": "0.0.0",
131
131
  "watchify": "^4.0.0",
132
- "webdriverio": "^4.14.4",
133
- "xmldom": "^0.6.0"
132
+ "webdriverio": "^4.14.4"
134
133
  },
135
134
  "mocha": {
136
135
  "reporter": "spec",
@@ -0,0 +1,16 @@
1
+ ## What?
2
+ ## Why?
3
+ ## How?
4
+ ## Testing?
5
+ ## Screenshots (optional)
6
+ ## Anything Else? (optional)
7
+ ## Check list
8
+
9
+ - [ ] I have reviewed my own pull request for linting issues (e.g. adding new lines)
10
+ - [ ] I have written tests (if relevant)
11
+ - [ ] I have created a JIRA number for my branch
12
+ - [ ] I have created a JIRA number for my commit
13
+ - [ ] I have followed the chris beams method for my commit https://cbea.ms/git-commit/
14
+ here is an [example commit](https://github.com/UKHomeOfficeForms/hof/commit/810959f391187c7c4af6db262bcd143b50093a6e)
15
+ - [ ] Ensure drone builds are green especially tests
16
+ - [ ] I will squash the commits before merging
@@ -2,6 +2,7 @@
2
2
  "fields": {
3
3
  "landing-page-radio": {
4
4
  "legend": "Which form would you like to explore?",
5
+ "hint": "Choose one of the options below and press continue.",
5
6
  "options": {
6
7
  "basic-form": {
7
8
  "label": "Basic form"
@@ -18,7 +19,7 @@
18
19
  "label": "Full name"
19
20
  },
20
21
  "dateOfBirth": {
21
- "legend": "Date of birth",
22
+ "legend": "What is your date of birth?",
22
23
  "hint": "For example, 31 10 1990"
23
24
  },
24
25
  "building": {
@@ -56,7 +57,7 @@
56
57
  }
57
58
  },
58
59
  "countryOfHearing": {
59
- "label": "Country of hearing",
60
+ "legend": "What country was the appeal lodged?",
60
61
  "options": {
61
62
  "englandAndWales": {
62
63
  "label": "England and Wales"
@@ -80,49 +81,45 @@
80
81
  "legend": "International phone number"
81
82
  },
82
83
  "complaintDetails": {
83
- "label": "Complaint details"
84
+ "label": "Complaint details",
85
+ "hint": "Briefly summarise your complaint. Include anything that can help our investigation."
86
+ },
87
+ "whatHappened": {
88
+ "label": "What happened",
89
+ "hint": "Briefly summarise what happened."
84
90
  },
85
91
  "countrySelect": {
86
- "label": "Select a country",
92
+ "label": "Which country are you based in?",
87
93
  "hint": "Start to type the country name and options will appear"
88
94
  },
89
95
  "appealStages": {
90
96
  "label": "Appeal stage",
97
+ "hint": "Choose an appeal stage from the drop down menu",
91
98
  "options": {
92
99
  "null": "Select..."
93
100
  }
94
101
  }
95
102
  },
96
103
  "journey": {
97
- "header": "HOF Bootstrap Sandbox Form"
104
+ "header": "HOF Bootstrap Sandbox Form",
105
+ "confirmation": {
106
+ "details": "Your reference number <br><strong>HDJ2123F</strong>"
107
+ }
98
108
  },
99
109
  "pages": {
100
110
  "landing-page": {
101
- "header": "Landing page",
102
- "intro": "Choose one of the options below and press continue."
111
+ "header": "Landing page"
103
112
  },
104
113
  "build-your-own-form": {
105
114
  "title": "Build your own form",
106
115
  "subheader": "Access the build your own form guidance link"
107
116
  },
108
- "name": {
109
- "header": "What is your full name?"
110
- },
111
- "dob": {
112
- "header": "What is your date of birth?"
113
- },
114
117
  "address": {
115
118
  "header": "What is your address in the UK?",
116
119
  "intro": "If you have no fixed address, enter an address where we can contact you."
117
120
  },
118
- "checkboxes": {
119
- "header": "Where does your money come from each month?"
120
- },
121
- "radio": {
122
- "header": "What country was the appeal lodged?"
123
- },
124
- "country-select": {
125
- "header": "What country is your address located?"
121
+ "name": {
122
+ "header": "What is your full name?"
126
123
  },
127
124
  "email": {
128
125
  "header": "Enter your email address"
@@ -130,14 +127,6 @@
130
127
  "phone-number": {
131
128
  "header": "Enter your phone number"
132
129
  },
133
- "text-input-area": {
134
- "header": "What are the details of your complaint?",
135
- "intro": "Briefly summarise your complaint. Include anything that can help our investigation."
136
- },
137
- "select": {
138
- "header": "What is the appeal stage?",
139
- "intro": "Choose an appeal stage from the drop down menu"
140
- },
141
130
  "confirm": {
142
131
  "header": "Check your answers before submitting your application.",
143
132
  "sections": {
@@ -161,6 +150,9 @@
161
150
  },
162
151
  "complaintDetails": {
163
152
  "header": "Complaint details"
153
+ },
154
+ "whatHappened": {
155
+ "header": "What happened"
164
156
  }
165
157
  }
166
158
  },
@@ -215,7 +207,11 @@
215
207
  },
216
208
  "complaintDetails": {
217
209
  "default": "Enter details about why you are making a complaint",
218
- "maxlength": "Keep to the 5000 character limit"
210
+ "maxlength": "Keep to the {{maxlength}} character limit"
211
+ },
212
+ "whatHappened": {
213
+ "default": "Enter details about what happened",
214
+ "maxword": "Keep to the {{maxword}} word limit"
219
215
  },
220
216
  "appealStages": {
221
217
  "required": "Select an appeal stage from the list"
@@ -16,7 +16,7 @@
16
16
  "author": "",
17
17
  "dependencies": {
18
18
  "govuk-frontend": "3.14",
19
- "jquery": "^3.6.0",
19
+ "jquery": "^3.7.1",
20
20
  "sass": "^1.53.0",
21
21
  "typeahead-aria": "^1.0.4"
22
22
  },