lanuv-parser
Advanced tools
Comparing version 0.2.0 to 0.2.1
37
index.js
@@ -20,5 +20,9 @@ 'use strict' | ||
*/ | ||
const query = (url) => { | ||
const query = (url, options = {}) => { | ||
return new Promise((resolve, reject) => { | ||
request(url, function (error, response, body) { | ||
request({ | ||
url, | ||
method: options.method ? options.method : 'GET', | ||
form: options.form ? options.form : undefined | ||
}, function (error, response, body) { | ||
if (error) { | ||
@@ -41,3 +45,3 @@ reject(error) | ||
* | ||
* @param {*} options | ||
* @param options.allStations return all stations if true | ||
* @returns Promise resolves with an array of all luqs stations | ||
@@ -47,3 +51,28 @@ */ | ||
return new Promise((resolve, reject) => { | ||
query(messorteUrl) | ||
let requestOptions | ||
const { status, allStations } = options | ||
if (status) { | ||
requestOptions = { | ||
method: 'POST', | ||
form: { | ||
auswahl_plz: 'alle', | ||
auswahl_status: status, | ||
auswahl_klassifizierung: 'alle' | ||
} | ||
} | ||
} | ||
if (allStations) { | ||
console.info('Option allStations is deprecated and will be removed in a future release!') | ||
requestOptions = { | ||
method: 'POST', | ||
form: { | ||
auswahl_plz: 'alle', | ||
auswahl_status: 'alle', | ||
auswahl_klassifizierung: 'alle' | ||
} | ||
} | ||
} | ||
query(messorteUrl, requestOptions) | ||
.then($ => { | ||
@@ -50,0 +79,0 @@ const stations = [] |
@@ -1,5 +0,4 @@ | ||
{ | ||
"name": "lanuv-parser", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Parse LANUV website for LUQS (Air Quality) stations", | ||
@@ -13,3 +12,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=10" | ||
"node": ">=14" | ||
}, | ||
@@ -16,0 +15,0 @@ "scripts": { |
@@ -31,2 +31,7 @@ # lanuv-parser | ||
Optionally accepts an `options` object as first parameter: | ||
- `status: aktiv|inaktiv|alle` returns stations with the specified status | ||
- `allStations: true` returns all active and inactive stations. Overrides the `status` option **Deprecated** | ||
### luqs.station(kuerzel) | ||
@@ -33,0 +38,0 @@ Returns detailed information about a specific LUQS station |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8430
172
45