@govuk-pay/pay-js-commons 4.0.17 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -4,6 +4,7 @@ Reusable js scripts for GOV.UK Pay Node.js projects
|
|
|
4
4
|
- [Browsered scripts](#browsered-scripts)
|
|
5
5
|
- [Utilities](#utilities)
|
|
6
6
|
- [Nunjucks filters](#nunjucks-filters)
|
|
7
|
+
- [HTTPS base client](#https-base-client)
|
|
7
8
|
- [Releasing a new version](#releasing-a-new-version)
|
|
8
9
|
|
|
9
10
|
## Browsered scripts
|
|
@@ -144,10 +145,10 @@ i.e. ``< > ; : ` ( ) " \' = | , ~ [ ]``
|
|
|
144
145
|
|
|
145
146
|
## Utilities
|
|
146
147
|
|
|
147
|
-
These are small functions that power the nunjucks filters but can also be used for server side stuff too.
|
|
148
|
-
|
|
149
148
|
### Nunjucks filters
|
|
150
149
|
|
|
150
|
+
These are small functions that power the nunjucks filters but can also be used for server side stuff too.
|
|
151
|
+
|
|
151
152
|
These get loaded in to the Nunjucks environment and then can apply changes to variables in templates.
|
|
152
153
|
|
|
153
154
|
For example if a country comes in as ISO code `EN` it can be converted to it’s name like so
|
|
@@ -165,6 +166,12 @@ Or a pence value can be converted to GBP
|
|
|
165
166
|
</dl>
|
|
166
167
|
```
|
|
167
168
|
|
|
169
|
+
### Https base client
|
|
170
|
+
|
|
171
|
+
Used in our Node.js apps to call internal APIs such as connector or ledger.
|
|
172
|
+
|
|
173
|
+
Uses the NPM Axios library.
|
|
174
|
+
|
|
168
175
|
## Releasing
|
|
169
176
|
|
|
170
177
|
After a pull request is merged, Concourse will automatically create a new release pull request that increments the package version.
|
package/lib/index.js
CHANGED
|
@@ -5,6 +5,7 @@ var utils = require('./utils');
|
|
|
5
5
|
var nunjucksFilters = require('./nunjucks-filters');
|
|
6
6
|
var logging = require('./logging');
|
|
7
7
|
var constants = require('./constants');
|
|
8
|
+
var HttpsBaseClient = require('./utils/https-base-client/https-base-client');
|
|
8
9
|
|
|
9
10
|
// Add to window.GOVUKPAY if in browser context
|
|
10
11
|
if (typeof window !== 'undefined') {
|
|
@@ -18,5 +19,6 @@ module.exports = {
|
|
|
18
19
|
utils: utils,
|
|
19
20
|
nunjucksFilters: nunjucksFilters,
|
|
20
21
|
logging: logging,
|
|
21
|
-
constants: constants
|
|
22
|
+
constants: constants,
|
|
23
|
+
HttpsBaseClient: HttpsBaseClient
|
|
22
24
|
};
|
package/lib/utils/{axios-base-client/axios-base-client.js → https-base-client/https-base-client.js}
RENAMED
|
@@ -23,16 +23,16 @@ var https = require('https');
|
|
|
23
23
|
var axios = require('axios');
|
|
24
24
|
var _require = require('./errors'),
|
|
25
25
|
RESTClientError = _require.RESTClientError;
|
|
26
|
-
var
|
|
27
|
-
function
|
|
28
|
-
_classCallCheck(this,
|
|
26
|
+
var HttpsBaseClient = /*#__PURE__*/function () {
|
|
27
|
+
function HttpsBaseClient(app) {
|
|
28
|
+
_classCallCheck(this, HttpsBaseClient);
|
|
29
29
|
this._app = app;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Configure the client. Should only be called once.
|
|
34
34
|
*/
|
|
35
|
-
_createClass(
|
|
35
|
+
_createClass(HttpsBaseClient, [{
|
|
36
36
|
key: "configure",
|
|
37
37
|
value: function configure(baseURL, options) {
|
|
38
38
|
var _this = this;
|
|
@@ -49,7 +49,7 @@ var Client = /*#__PURE__*/function () {
|
|
|
49
49
|
}),
|
|
50
50
|
headers: {
|
|
51
51
|
'Content-Type': 'application/json',
|
|
52
|
-
|
|
52
|
+
Accept: 'application/json'
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
55
|
this._axios.interceptors.request.use(function (config) {
|
|
@@ -190,8 +190,6 @@ var Client = /*#__PURE__*/function () {
|
|
|
190
190
|
return this._axios.delete(url, this._getConfigWithDescription(config, description));
|
|
191
191
|
}
|
|
192
192
|
}]);
|
|
193
|
-
return
|
|
193
|
+
return HttpsBaseClient;
|
|
194
194
|
}();
|
|
195
|
-
module.exports =
|
|
196
|
-
Client: Client
|
|
197
|
-
};
|
|
195
|
+
module.exports = HttpsBaseClient;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@govuk-pay/pay-js-commons",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "Reusable js scripts for GOV.UK Pay Node.js projects",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": "^18.17.1"
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"prepare": "npm run transpile && npm run browserify-analytics",
|
|
21
21
|
"test": "npm run jest-tests npm && npm run karma-tests",
|
|
22
22
|
"karma-tests": "karma start",
|
|
23
|
-
"jest-tests": "jest src/analytics src/utils/
|
|
23
|
+
"jest-tests": "jest src/analytics src/utils/https-base-client/https-base-client.test.js",
|
|
24
24
|
"lint": "standard --fix"
|
|
25
25
|
},
|
|
26
26
|
"repository": {
|
|
File without changes
|