@caruuto/caruuto-js 0.2.1 → 0.3.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/CHANGELOG.md +12 -0
- package/lib/helpers.js +2 -2
- package/lib/performFetch.js +6 -0
- package/package.json +3 -4
package/CHANGELOG.md
CHANGED
|
@@ -4,3 +4,15 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
7
|
+
|
|
8
|
+
## 0.3.1 - 2024-01-16
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Downgrade required Node version to >=12
|
|
13
|
+
|
|
14
|
+
## 0.3.0 - 2024-01-09
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- If an API key is provided to the constructor, it is added to the request headers as Authorization: Api-Key-v1 <key>
|
package/lib/helpers.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const querystring = require('query-string')
|
|
2
|
-
const
|
|
2
|
+
const url = require('url')
|
|
3
3
|
|
|
4
4
|
module.exports = function (CaruutoClient) {
|
|
5
5
|
/**
|
|
@@ -144,7 +144,7 @@ module.exports = function (CaruutoClient) {
|
|
|
144
144
|
* @api private
|
|
145
145
|
*/
|
|
146
146
|
CaruutoClient.prototype._createRequestObject = function (options) {
|
|
147
|
-
const parsedUri =
|
|
147
|
+
const parsedUri = url.parse(options.uri)
|
|
148
148
|
const requestObject = Object.assign({}, options, {
|
|
149
149
|
uri: {
|
|
150
150
|
href: parsedUri.href,
|
package/lib/performFetch.js
CHANGED
|
@@ -25,12 +25,18 @@ module.exports = function (CaruutoClient) {
|
|
|
25
25
|
*/
|
|
26
26
|
CaruutoClient.prototype._processRequest = async function (requestObject) {
|
|
27
27
|
const fetch = resolveFetch(this.options.fetch)
|
|
28
|
+
|
|
28
29
|
const options = {
|
|
29
30
|
headers: Object.assign({}, requestObject.headers),
|
|
30
31
|
method: requestObject.method,
|
|
31
32
|
uri: requestObject.uri.href
|
|
32
33
|
}
|
|
33
34
|
|
|
35
|
+
// Add authorization header if an API key has been provided.
|
|
36
|
+
if (this.options.caruutoApiKey) {
|
|
37
|
+
options.headers.authorization = `Api-Key-v1 ${this.options.caruutoApiKey}`
|
|
38
|
+
}
|
|
39
|
+
|
|
34
40
|
if (requestObject.body) {
|
|
35
41
|
options.body = JSON.stringify(requestObject.body)
|
|
36
42
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caruuto/caruuto-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "A high-level library for interacting with Caruuto",
|
|
5
5
|
"exports": "./index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -14,8 +14,7 @@
|
|
|
14
14
|
"debug": "^2.6.1",
|
|
15
15
|
"got": "^11.0.0",
|
|
16
16
|
"mocha": "^10.2.0",
|
|
17
|
-
"query-string": "5.0.1"
|
|
18
|
-
"url-parse": "1.4.3"
|
|
17
|
+
"query-string": "5.0.1"
|
|
19
18
|
},
|
|
20
19
|
"repository": {
|
|
21
20
|
"type": "git",
|
|
@@ -25,7 +24,7 @@
|
|
|
25
24
|
"url": "https://github.com/Caruuto/caruuto-js/issues"
|
|
26
25
|
},
|
|
27
26
|
"engines": {
|
|
28
|
-
"node": ">=
|
|
27
|
+
"node": ">=12"
|
|
29
28
|
},
|
|
30
29
|
"husky": {
|
|
31
30
|
"hooks": {
|