fix dependency major version changes
This commit is contained in:
parent
d0509f14ae
commit
994b55530c
6
.vscode/launch.json
vendored
6
.vscode/launch.json
vendored
|
@ -36,5 +36,11 @@
|
|||
"program": "${workspaceFolder}/index.js",
|
||||
"outputCapture": "std",
|
||||
}
|
||||
],
|
||||
"compounds": [
|
||||
{
|
||||
"name": "Compound",
|
||||
"configurations": ["Frontend", "Server"]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -6,14 +6,12 @@ const https = require('https');
|
|||
// url parsing
|
||||
const queryString = require('querystring');
|
||||
|
||||
|
||||
|
||||
// return an express router
|
||||
module.exports = (req, res) => {
|
||||
// add out-going headers
|
||||
const headers = {};
|
||||
headers['user-agent'] = '(WeatherStar 4000+, ws4000@netbymatt.com)';
|
||||
headers['accept'] = req.headers.accept;
|
||||
headers.accept = req.headers.accept;
|
||||
|
||||
// get query paramaters if the exist
|
||||
const queryParams = Object.keys(req.query).reduce((acc, key) => {
|
||||
|
@ -22,16 +20,16 @@ module.exports = (req, res) => {
|
|||
// add the paramter to the resulting object
|
||||
acc[key] = req.query[key];
|
||||
return acc;
|
||||
},{});
|
||||
}, {});
|
||||
let query = queryString.encode(queryParams);
|
||||
if (query.length > 0) query = '?' + query;
|
||||
if (query.length > 0) query = `?${query}`;
|
||||
|
||||
// get the page
|
||||
https.get('https://api.weather.gov' + req.path + query, {
|
||||
https.get(`https://api.weather.gov${req.path}${query}`, {
|
||||
headers,
|
||||
}, getRes => {
|
||||
}, (getRes) => {
|
||||
// pull some info
|
||||
const {statusCode} = getRes;
|
||||
const { statusCode } = getRes;
|
||||
// pass the status code through
|
||||
res.status(statusCode);
|
||||
|
||||
|
@ -39,8 +37,7 @@ module.exports = (req, res) => {
|
|||
res.header('content-type', getRes.headers['content-type']);
|
||||
// pipe to response
|
||||
getRes.pipe(res);
|
||||
|
||||
}).on('error', e=>{
|
||||
}).on('error', (e) => {
|
||||
console.error(e);
|
||||
});
|
||||
};
|
|
@ -24,6 +24,7 @@ class CurrentWeather extends WeatherDisplay {
|
|||
stationNum += 1;
|
||||
try {
|
||||
// station observations
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
observations = await utils.fetch.json(`${station.id}/observations`, {
|
||||
cors: true,
|
||||
data: {
|
||||
|
@ -38,8 +39,6 @@ class CurrentWeather extends WeatherDisplay {
|
|||
observations = undefined;
|
||||
throw new Error(`Unable to get observations: ${station.properties.stationIdentifier}, trying next station`);
|
||||
}
|
||||
|
||||
// TODO: add retry for further stations if observations are unavailable
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
|
|
@ -152,8 +152,9 @@ class Radar extends WeatherDisplay {
|
|||
day,
|
||||
hour,
|
||||
minute,
|
||||
}, {
|
||||
zone: 'UTC',
|
||||
}).setZone();
|
||||
});
|
||||
} else {
|
||||
time = DateTime.fromHTTP(response.headers.get('last-modified')).setZone();
|
||||
}
|
||||
|
|
|
@ -256,8 +256,8 @@ const utils = (() => {
|
|||
let corsUrl = _url;
|
||||
if (params.cors === true) corsUrl = rewriteUrl(_url);
|
||||
const url = new URL(corsUrl);
|
||||
// force url to secure
|
||||
url.protocol = 'https:';
|
||||
// match the security protocol
|
||||
url.protocol = window.location.protocol;
|
||||
// add parameters if necessary
|
||||
if (params.data) {
|
||||
Object.keys(params.data).forEach((key) => {
|
||||
|
|
Loading…
Reference in a new issue