-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
58 lines (58 loc) · 14.8 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
module.exports = {
alerts: function alerts() {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/alerts`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
alertsActive: function alertsActive() {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/alerts/active`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
alertsActiveCount: function alertsActiveCount() {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/alerts`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
alertsActiveZone: function alertsActiveZone(zoneId) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/alerts/active/zone/${zoneId}`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
alertsActiveArea: function alertsActiveArea(area) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/alerts/active/area/${area}`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
alertsActiveRegion: function alertsActiveRegion(region) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/alerts/active/region/${region}`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
alertsTypes: function alertsTypes() {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/alerts/types`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
alertsId: function alertsId(id) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/alerts/${id}`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
aviationCwsus: function aviationCwsus(cwsuId) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/aviation/cwsus/${cwsuId}`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
aviationCwsusCwsuidCwas: function aviationCwsusCwsuidCwas(cwsuId) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/aviation/cwsus/${cwsuId}/cwas`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
aviationCwsusCwsuidCwasDateSequence: function aviationCwsusCwsuidCwasDateSequence(cwsuId, date, sequence) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/aviation/cwsus/${cwsuId}/cwas/${date}/${sequence}`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
aviationSigmets: function alerts() {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/aviation/sigmets`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
aviationSigmetsAtsu: function aviationSigmetsAtsu(atsu) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/aviation/sigmets/${atsu}`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
aviationSigmetsAtsuDate: function aviationSigmetsAtsuDate(atsu, date) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/aviation/sigmets/${atsu}/${date}`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
aviationSigmetsAtsuDateTime: function aviationSigmetsAtsuDateTime(atsu, date, time) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/aviation/sigmets/${atsu}/${date}/${time}`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
glossary: function glossary() {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/glossary`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
gridpointsWfoXY: function gridpointsWfoXY(wfo, x, y) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/gridpoints/${wfo}/${x},${y}`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
gridpointsWfoXYForecast: function gridpointsWfoXYForecast(wfo, x, y) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/gridpoints/${wfo}/${x},${y}/forecast`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
gridpointsWfoXYForecastHourly: function gridpointsWfoXYForecastHourly(wfo, x, y) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/gridpoints/${wfo}/${x},${y}/forecast/hourly`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
gridpointsWfoXYStations: function gridpointsWfoXYStations() {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/gridpoints/${wfo}/${x},${y}/stations`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
stationsStationidObservations: function stationsStationidObservations(stationId) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/stations/${stationId}/observations`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
stationsStationidObservationsLatest: function stationsStationidObservationsLatest(stationId) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/stations/${stationId}/observations/latest`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
stationsStationidObservationsTime: function stationsStationidTime(stationId, time) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/stations/${stationId}/${time}`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
stationsStationidTafs: function stationsStationidTafs(stationId) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/stations/${stationId}/tafs`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
stationsStationidTafsDateTime: function stationsStationidTafsDateTime(stationId, date, time) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/stations/${stationId}/tafs/${date}/${time}`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
stations: function stations() {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/stations`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
stationsStationid: function stationsStationid(stationId) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/stations/${stationId}`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
offices: function offices(officeId) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/offices/${stationId}`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
officesOfficeidHeadlinesHeadline: function officesOfficeidHeadlinesHeadline(officeId, headlineId) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/offices/${officeId}/headlines/${headlineId}`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
officesOfficeidHeadlines: function officesOfficeidHeadlines(officeId) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/offices/${officeId}/headlines`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
points: function points(point) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/points/${point}`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
radarServers: function radarServers() {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/radar/servers`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
radarServersId: function radarServersId(id) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/radar/servers/${id}`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
radarStations: function radarStations() {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/radar/stations`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
radarStationsStationid: function radarStationsStationid(stationId) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/radar/stations/${stationId}`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
radarStationsStationidAlarms: function radarStationsStationidAlarms(stationId) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/radar/stations/${stationId}/alarms`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
radarQueues: function radarQueues(host) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/radar/queues/${host}`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
radarProfilers: function radarProfiles(stationId) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/radar/profilers/${stationId}`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
products: function products() {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/products`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
productsLocations: function productsLocations() {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/productsLocations`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
productsTypes: function productsTypes() {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/products/types`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
productsProductid: function productsProductid(productId) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/products/${productId}`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
productsTypesTypeid: function productsTypeTypeid(typeId) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/products/types/${typeId}`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
productsTypesTypeidLocations: function productsTypeTypeidLocations(typeId) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/products/types/${typeId}/locations`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
productsLocationsLocationidTypes: function productsLocationsLocationidTypes(locationId) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/products/locations/${locationId}/types`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
productsTypesTypeidLocationsLocationid: function productsTypesTypeidLocationsLocationid(typeId, locationId) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/products/types/${typeId}/locations/${locationId}`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
zones: function zones() {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/zones`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
zonesType: function zonesType(type) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/zones/${type}`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
zonesTypeZoneid: function zonesTypeZoneid(type, zoneId) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/zones/${type}/${zoneId}`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
zonesTypeZoneidForecast: function zonesTypeZoneidForecast(type, zoneId) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/zones/${type}/${zoneId}/forecast`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
zonesForecastZoneidObservations: function zonesForecastZoneidObservations(zoneId) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/zones/forecast/${zoneId}/observations`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
zonesForecastZoneidStations: function zonesForecastZoneidStations(zoneId) {return new Promise(function (resolve, reject) { fetch(`https://api.weather.gov/zones/forecast/${zoneId}/stations`).then(res => {return res.json()}).then(data => {resolve(data);}).catch(error => {reject(error);});})},
// Built-in functions
helloWorld: function helloWorld() {console.log("Hello World")},
temperature: function temperature(point) {return new Promise(function(resolve, reject) {fetch(`https://api.weather.gov/points/${point}`).then(res => {res.json().then((out) => {fetch(`https://api.weather.gov/gridpoints/${out.properties.cwa}/${out.properties.gridX},${out.properties.gridY}/forecast/hourly`).then(res => {res.json().then((out) => {console.log(out.properties.periods[0].temperature)}).then(data => resolve(data));}).catch(error => {reject(error);});});});});},
shortForecast: function shortForecast(point) {return new Promise(function(resolve, reject) {fetch(`https://api.weather.gov/points/${point}`).then(res => {res.json().then((out) => {fetch(`https://api.weather.gov/gridpoints/${out.properties.cwa}/${out.properties.gridX},${out.properties.gridY}/forecast/hourly`).then(res => {res.json().then((out) => {console.log(out.properties.periods[0].shortForecast)}).then(data => resolve(data));}).catch(error => {reject(error);});});});});}
};