@apiverve/moonphases 1.0.2 → 1.1.2
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 +10 -12
- package/index.js +17 -8
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -47,15 +47,13 @@ Using the API client, you can perform requests to the API.
|
|
|
47
47
|
###### Define Query
|
|
48
48
|
|
|
49
49
|
```
|
|
50
|
-
|
|
51
|
-
date: "05-15-2024"
|
|
52
|
-
};
|
|
50
|
+
This API does not require a Query
|
|
53
51
|
```
|
|
54
52
|
|
|
55
53
|
###### Simple Request (using Callback)
|
|
56
54
|
|
|
57
55
|
```
|
|
58
|
-
api.execute(
|
|
56
|
+
api.execute(function (error, data) {
|
|
59
57
|
if (error) {
|
|
60
58
|
return console.error(error);
|
|
61
59
|
} else {
|
|
@@ -71,16 +69,16 @@ api.execute(query, function (error, data) {
|
|
|
71
69
|
"status": "ok",
|
|
72
70
|
"error": null,
|
|
73
71
|
"data": {
|
|
74
|
-
"phase": "Waxing
|
|
75
|
-
"phaseEmoji": "
|
|
72
|
+
"phase": "Waxing Gibbous",
|
|
73
|
+
"phaseEmoji": "🌔",
|
|
76
74
|
"waxing": true,
|
|
77
75
|
"waning": false,
|
|
78
|
-
"lunarAge":
|
|
79
|
-
"lunarAgePercent": 0.
|
|
80
|
-
"lunationNumber":
|
|
81
|
-
"lunarDistance":
|
|
82
|
-
"nextFullMoon": "2024-
|
|
83
|
-
"lastFullMoon": "2024-
|
|
76
|
+
"lunarAge": 11.631925154626766,
|
|
77
|
+
"lunarAgePercent": 0.39389413006358609,
|
|
78
|
+
"lunationNumber": 1256,
|
|
79
|
+
"lunarDistance": 60.524038551213266,
|
|
80
|
+
"nextFullMoon": "2024-08-17T00:00:00Z",
|
|
81
|
+
"lastFullMoon": "2024-06-18T00:00:00Z"
|
|
84
82
|
}
|
|
85
83
|
}
|
|
86
84
|
```
|
package/index.js
CHANGED
|
@@ -24,11 +24,16 @@ class moonphasesWrapper {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
async execute(query, callback) {
|
|
27
|
-
if
|
|
28
|
-
|
|
27
|
+
if(arguments.length > 1) {
|
|
28
|
+
if (!query || typeof query !== 'object') {
|
|
29
|
+
throw new Error('Query parameters must be provided as an object.');
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
callback = query;
|
|
33
|
+
query = {};
|
|
29
34
|
}
|
|
30
35
|
|
|
31
|
-
var requiredParams = [
|
|
36
|
+
var requiredParams = [];
|
|
32
37
|
if (requiredParams.length > 0) {
|
|
33
38
|
for (var i = 0; i < requiredParams.length; i++) {
|
|
34
39
|
if (!query[requiredParams[i]]) {
|
|
@@ -68,11 +73,15 @@ class moonphasesWrapper {
|
|
|
68
73
|
|
|
69
74
|
constructURL(query) {
|
|
70
75
|
let url = this.baseURL;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
|
|
77
|
+
if(query && typeof query === 'object')
|
|
78
|
+
{
|
|
79
|
+
if (Object.keys(query).length > 0) {
|
|
80
|
+
const queryString = Object.keys(query)
|
|
81
|
+
.map(key => `${encodeURIComponent(key)}=${encodeURIComponent(query[key])}`)
|
|
82
|
+
.join('&');
|
|
83
|
+
url += `?${queryString}`;
|
|
84
|
+
}
|
|
76
85
|
}
|
|
77
86
|
return url;
|
|
78
87
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apiverve/moonphases",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Moon Phases is a simple tool for getting the moon phases. It returns the moon phase for a given date.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
},
|
|
21
21
|
"homepage": "https://github.com/apiverve/moonphases-API",
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"mocha": "^
|
|
24
|
-
"chai": "^
|
|
25
|
-
"dotenv": "^
|
|
23
|
+
"mocha": "^10.4.0",
|
|
24
|
+
"chai": "^5.1.1",
|
|
25
|
+
"dotenv": "^16.4.5"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"node-fetch": "3.3.2",
|
|
29
|
-
"promise": "^
|
|
30
|
-
"axios": "
|
|
29
|
+
"promise": "^8.3.0",
|
|
30
|
+
"axios": "1.6.8"
|
|
31
31
|
}
|
|
32
32
|
}
|