Skip to content

Commit da8bba5

Browse files
Jeffrey BrownJeffrey Brown
Jeffrey Brown
authored and
Jeffrey Brown
committed
Final APOD Testing, Updates to README
1 parent ab38d02 commit da8bba5

File tree

5 files changed

+106
-117
lines changed

5 files changed

+106
-117
lines changed

README.md

+50-6
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@
6868

6969
The `key` value is required for all calls. You can leave it as `DEMO_KEY` and the functions will still work as intended, but the API call limitations will be stricter. Otherwise, request a free API code from NASA's website and use that as the key value (recommended).
7070

71+
Currently, Celestial Bodies has built-in functionality for:<br>
72+
<a href="#apod">Astronomy Image of the Day</a><br>
73+
<a href="#asteroids">Near Earth Orbit Web Service</a><br>
74+
<a href="#donki">Space Weather Database of Notifications, Knowledge, and Information (DONKI)</a><br>
75+
<a href="#earth">Earth - Landsat Imagery</a><br>
76+
77+
78+
79+
80+
7181
#### APOD
7282
The `apod()` function is used to leverage the Astronomy Picture of the Day API.
7383

@@ -96,6 +106,8 @@
96106

97107

98108

109+
110+
99111
#### Asteroids
100112
The `asteroids()` function provides access to NASA's Near Earth Object Web Service. This call has three separate modes - ``feed``, ``lookup``, and ``browse``.
101113

@@ -146,6 +158,10 @@
146158
});
147159
```
148160

161+
162+
163+
164+
149165
#### DONKI
150166
The `donki()` function provides access to the Space Weather Database of Notifications, Knowledge, and Information (DONKI). This API is particularly useful for space weather forecasters, scientists, and the general space science community.
151167

@@ -157,8 +173,7 @@
157173

158174
The `start_date` and `end_date` parameters are optional, and if omitted from the payload the request will default to pulling the last 30 days worth of data.
159175

160-
161-
```js
176+
```js
162177
const payload = {
163178
start_date: '2021-01-01', // optional //
164179
end_date: '2021-01-02', // optional //
@@ -171,6 +186,39 @@
171186
});
172187
```
173188

189+
##### Coronal Mass Ejection Analysis (CME+)
190+
191+
##### Geomagnetic Storm (GST)
192+
193+
##### Interplanetary Shock (IPS)
194+
195+
##### Solar Flare (FLR)
196+
197+
##### Solar Energetic Particle (SEP)
198+
199+
##### Magnetopause Crossing (MPC)
200+
201+
##### Radiation Belt Enhancement (RBE)
202+
203+
##### High Speed Stream (HSS)
204+
205+
##### WSA+EnlilSimulation (WSA)
206+
207+
##### Notifications
208+
209+
210+
211+
#### Earth
212+
213+
The `earth()` function is designed to give you an easy to use taste of what Landsat imagery data can provide. There are two different types for this API - `imagery` and `assets` - which serve slightly different purposes.
214+
215+
##### Imagery
216+
217+
This endpoint retrieves the Landsat 8 image for the supplied location and date.
218+
219+
##### Assets
220+
221+
This endpoint retrieves the date-times and asset names for closest available imagery for a supplied location and date.
174222

175223
## Contributing
176224

@@ -183,7 +231,3 @@
183231

184232
##### Misc. Assets
185233
<a href="https://looka.com/">Looka</a>
186-
187-
## Bonus
188-
189-
Please :star: the project if you enjoy it - much appreciated!

lib/celestial.js

-108
This file was deleted.

lib/donki.js

+20-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const axios = require('axios')
33
const Joi = require('joi')
44

55
// import utilities //
6-
const dateUtils = require('../utils/dates.js')
76

87
// neows (near earth object web service) //
98
function donki (payload, callback) {
@@ -12,7 +11,6 @@ function donki (payload, callback) {
1211

1312
// donki request type is coronal mass ejection (cme) //
1413
if (type === 'cme') {
15-
1614
// define validation schema //
1715
const validationSchema = Joi.object({
1816
end_date: Joi.string().regex(/\d{4}-\d{2}-\d{2}/, { name: 'endDate' }).optional(),
@@ -40,6 +38,26 @@ function donki (payload, callback) {
4038

4139
// define request url //
4240
request = `https://api.nasa.gov/DONKI/CME?${requestURLParameters}`
41+
} else if (type === 'cme+') {
42+
return 'CME+ Coming Soon'
43+
} else if (type === 'gst') {
44+
return 'GST Coming Soon'
45+
} else if (type === 'ips') {
46+
return 'IPS Coming Soon'
47+
} else if (type === 'flr') {
48+
return 'FLR Coming Soon'
49+
} else if (type === 'sep') {
50+
return 'SEP Coming Soon'
51+
} else if (type === 'mpc') {
52+
return 'MPC Coming Soon'
53+
} else if (type === 'rbe') {
54+
return 'RBE Coming Soon'
55+
} else if (type === 'hss') {
56+
return 'HSS Coming Soon'
57+
} else if (type === 'wsa') {
58+
return 'WSA Coming Soon'
59+
} else if (type === 'notifications') {
60+
return 'Notifications Coming Soon'
4361
}
4462

4563
// api request //

lib/earth.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// import libraries //
2+
const axios = require('axios')
3+
const Joi = require('joi')
4+
5+
// import utilities //
6+
7+
// earth - landsat imagery //
8+
function earth (payload, callback) {
9+
const type = payload.type
10+
11+
// earth request type is imagery //
12+
if (type === 'imagery') {
13+
14+
// define request url //
15+
request = `https://api.nasa.gov/planetary/earth/imagery?${requestURLParameters}`
16+
} else if (type === 'assets') {
17+
18+
// define request url //
19+
request = `https://api.nasa.gov/planetary/earth/assets?${requestURLParameters}`
20+
}
21+
22+
// api request //
23+
return axios(request)
24+
.then((response) => {
25+
try {
26+
callback(response.data)
27+
return response.data
28+
} catch (error) {
29+
callback(response.data)
30+
return response.data
31+
}
32+
})
33+
}
34+
35+
module.exports.earth = earth

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "celestial-bodies",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"description": "Lightweight wrapper for interacting with NASA's API library.",
55
"repository": {
66
"type": "git",

0 commit comments

Comments
 (0)