@beauraines/node-helpers 4.0.4 → 4.0.6

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.
@@ -13,7 +13,7 @@ jobs:
13
13
 
14
14
  strategy:
15
15
  matrix:
16
- node-version: [16.x]
16
+ node-version: [16.x,18.x,20.x]
17
17
 
18
18
  steps:
19
19
  - uses: actions/checkout@v3
package/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [4.0.6](https://github.com/beauraines/node-helpers/compare/v4.0.4...v4.0.6) (2023-12-28)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **deps:** bump @azure/storage-blob from 12.14.0 to 12.15.0 ([3253e14](https://github.com/beauraines/node-helpers/commit/3253e14673cf645abcb0c964576bd7046b97fd29))
11
+ * **deps:** bump @azure/storage-blob from 12.15.0 to 12.16.0 ([5a058ce](https://github.com/beauraines/node-helpers/commit/5a058ce3baffd1bd79fe434ebd082ccba7fed667))
12
+ * **deps:** bump @azure/storage-blob from 12.16.0 to 12.17.0 ([8d17b3c](https://github.com/beauraines/node-helpers/commit/8d17b3ce1ef1e19f3ba804c6a391c279dcd13b86))
13
+ * **deps:** bump @azure/storage-queue from 12.13.0 to 12.14.0 ([317a87c](https://github.com/beauraines/node-helpers/commit/317a87c2fed24f3180b080a3fe0f1986fc886c64))
14
+ * **deps:** bump @azure/storage-queue from 12.14.0 to 12.15.0 ([1480375](https://github.com/beauraines/node-helpers/commit/14803753cee6c9b21eb4912d9ea08f772fcbee68))
15
+ * **deps:** bump @azure/storage-queue from 12.15.0 to 12.16.0 ([883fee4](https://github.com/beauraines/node-helpers/commit/883fee4bc959e1e02ea14e44a43d1cfaa2b40bea))
16
+ * **deps:** bump dayjs from 1.11.9 to 1.11.10 ([69be1aa](https://github.com/beauraines/node-helpers/commit/69be1aace097f6d6e244874315e65d2429353ee1))
17
+ * **deps:** bump node-fetch from 2.6.12 to 2.7.0 ([727c31c](https://github.com/beauraines/node-helpers/commit/727c31c4d789797f37b07af98b5aa00f77fe10f4))
18
+ * **deps:** bump sqlite from 4.2.1 to 5.0.1 ([#54](https://github.com/beauraines/node-helpers/issues/54)) ([1066aec](https://github.com/beauraines/node-helpers/commit/1066aec108fe771c268e76975fb0151bf5f1ef40))
19
+ * **deps:** bump sqlite from 5.0.1 to 5.1.1 ([30f2b0e](https://github.com/beauraines/node-helpers/commit/30f2b0ef9687d20ef2a58778a43ba43251901a91))
20
+
5
21
  ### [4.0.4](https://github.com/beauraines/node-helpers/compare/v4.0.1...v4.0.4) (2023-07-16)
6
22
 
7
23
 
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # Node Helpers
2
2
 
3
- This is a set of helpers for node. They're written for quick reuse rather than robust functions or efficiency. For instance, the database functions will create a new database connection every time. This is not efficient, but it makes making the function call simple.
3
+ This is a set of helpers for NodeJS. They're written for quick reuse rather than robust functions or efficiency. For instance, the database functions will create a new database connection every time. This is not efficient, but it makes making the function call simple.
4
4
 
5
- My use is primarily in quicker one off scripts that sometime morph into something long lasting...
5
+ My use is primarily in quicker one-off scripts that sometimes morph into something long-lasting...
6
6
 
7
7
 
8
8
  ## Azure Storage
9
9
 
10
- Get blob from Azure example, downloads `bar.jpg` from `foo` container to `baz.jgp`
10
+ Get blob from Azure example, downloads `bar.jpg` from `foo` container to `baz.jpg`
11
11
 
12
12
  ```javascript
13
13
  const AzureStorage = require('./src/azure.js')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beauraines/node-helpers",
3
- "version": "4.0.4",
3
+ "version": "4.0.6",
4
4
  "description": "Collection of node helpers",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -19,7 +19,7 @@
19
19
  "dayjs": "^1.11.7",
20
20
  "node-fetch": "^2.6.7",
21
21
  "sparkly": "^5.0.0",
22
- "sqlite": "^4.1.2",
22
+ "sqlite": "^5.0.1",
23
23
  "sqlite3": "^5.1.2"
24
24
  },
25
25
  "devDependencies": {
package/src/callAPI.js DELETED
@@ -1,147 +0,0 @@
1
- const fetch = require('node-fetch')
2
-
3
-
4
- // TODO query string builder?
5
- // Other than JSON responses?
6
-
7
- /**
8
- * Makes a GET request
9
- *
10
- * @param {string} url URL for request
11
- * @param {object} [headers] Headers object
12
- * @returns {Promise} JSON response
13
- * @throws {Error} if response is not okay
14
- */
15
- const getRequest = async (url,headers) => {
16
- const response = await fetch(url,{
17
- method: 'GET',
18
- headers,
19
- });
20
-
21
- let responseBody
22
- if (response.ok) {
23
- responseBody = await response.json()
24
- } else {
25
- throw new Error(response.statusText)
26
- }
27
- return responseBody
28
- }
29
-
30
- /**
31
- * Makes a GET request
32
- *
33
- * @param {string} url URL for request
34
- * @param {object} [headers] Headers object
35
- * @returns {Promise} Blob response
36
- * @throws {Error} if response is not okay
37
- */
38
- const getRequestBlob = async (url,headers) => {
39
- const response = await fetch(url,{
40
- method: 'GET',
41
- headers
42
- });
43
-
44
- let responseBody
45
- if (response.ok) {
46
- responseBody = await response.blob()
47
- } else {
48
- throw new Error(response.statusText)
49
- }
50
- return responseBody
51
- }
52
-
53
- /**
54
- * Makes synchronous POST request to a specified URL using Bearer Token authorization and
55
- * returns the JSON response
56
- *
57
- * @param {string} url
58
- * @param {object} requestBody
59
- * @param {string} token
60
- * @param {object} [headers]
61
- * @returns {object}
62
- * @throws {Error} if the response is not OK
63
- */
64
- const postRequest = async (url,requestBody,token,headers) => {
65
- const response = await fetch(url,{
66
- method: 'POST',
67
- headers: {
68
- 'Authorization': 'Bearer ' + token,
69
- 'Content-Type': 'application/json',
70
- ... headers
71
- },
72
- body: JSON.stringify(requestBody)
73
- });
74
-
75
- let responseBody
76
- if (response.ok) {
77
- responseBody = await response.json()
78
- } else {
79
- throw new Error(response.statusText)
80
- }
81
- return responseBody
82
- }
83
-
84
- /**
85
- * Makes synchronous POST request to a specified URL using Bearer Token authorization and
86
- * returns the JSON response
87
- *
88
- * @param url {string}
89
- * @param requestBody {object}
90
- * @param token {string}
91
- * @param [headers] {object}
92
- * @returns {object}
93
- * @throws {Error} if the response is not OK
94
- */
95
- const postRequestPaginated = async (url,requestBody,token,headers) => {
96
- let responseBody = await postRequest(url,requestBody,token,headers)
97
- if (responseBody.totalCount < responseBody.pageSize) {
98
- return responseBody
99
- }
100
-
101
- let requestBodies = []
102
- // TODO make these pagination properties arguments
103
- let pageSize = responseBody.pageSize
104
- let total = responseBody.totalCount
105
- let start = responseBody.start
106
- let end = responseBody.end
107
- let totalPages = 1
108
- while (end < total) {
109
- requestBodies.push(
110
- {
111
- ... requestBody,
112
- start: start + pageSize,
113
- end: end + pageSize
114
- }
115
- )
116
- totalPages++
117
- }
118
-
119
- let paginatedResponseBodyPromises = []
120
- for (const requestBody of requestBodies) {
121
- let paginatedResponseBody = postRequest(url,requestBody,token,headers)
122
- paginatedResponseBodyPromises.concat(paginatedResponseBody)
123
- }
124
-
125
- let paginatedResponseBodies = await Promise.all(paginatedResponseBodyPromises);
126
- for ( const body of paginatedResponseBodies ) {
127
- responseBody.data.concat(body.data)
128
- }
129
-
130
- // TODO update the pagination properties to show all data returned
131
- responseBody.start = 1,
132
- responseBody.end = end
133
- responseBody.totalPages = totalPages
134
- responseBody.pageSize = 500
135
- if (responseBody.totalCount != responseBody.data.length) {
136
- throw new Error('Response data does not equql total records')
137
- }
138
-
139
- return responseBody
140
- }
141
-
142
- module.exports = {
143
- getRequest,
144
- getRequestBlob,
145
- postRequest,
146
- postRequestPaginated
147
- }