flightradar24-client-ts
Advanced tools
Comparing version 1.0.0 to 1.1.0
import { AircraftData, AirlineDetail, Flight, RadarOptions, ZoneData } from './types'; | ||
import { AirportData } from './airportTypes'; | ||
export interface FlightRadarApiConfig { | ||
corsProxy?: string; | ||
} | ||
export declare const defaultRadarOptions: RadarOptions; | ||
import { FlightRadarApiConfig } from './config'; | ||
export declare class FlightRadarApi { | ||
@@ -8,0 +5,0 @@ private config; |
@@ -15,27 +15,15 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.FlightRadarApi = exports.defaultRadarOptions = void 0; | ||
const utils_1 = require("./utils"); | ||
exports.FlightRadarApi = void 0; | ||
const querystringify_1 = __importDefault(require("querystringify")); | ||
const endpoints_1 = require("./endpoints"); | ||
const cross_fetch_1 = __importDefault(require("cross-fetch")); | ||
exports.defaultRadarOptions = { | ||
FAA: true, | ||
FLARM: true, | ||
MLAT: true, | ||
ADSB: true, | ||
inAir: true, | ||
onGround: false, | ||
inactive: false, | ||
gliders: false, | ||
estimatedPositions: false, // if out of coverage | ||
}; | ||
const config_1 = require("./config"); | ||
class FlightRadarApi { | ||
constructor(config = { | ||
corsProxy: 'https://corsproxy.io/?', | ||
}) { | ||
constructor(config = config_1.defaultFlightRadarApiConfig) { | ||
this.config = config; | ||
} | ||
apiRequest(url, options = {}) { | ||
var _a, _b; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const res = yield (0, cross_fetch_1.default)(this.config.corsProxy ? this.config.corsProxy + url : url, Object.assign(Object.assign({}, (0, utils_1.getFetchOptions)()), options)); | ||
const res = yield (0, cross_fetch_1.default)(this.config.corsProxy ? this.config.corsProxy + url : url, Object.assign(Object.assign({}, (_b = (_a = this.config).fetchOptions) === null || _b === void 0 ? void 0 : _b.call(_a)), options)); | ||
if (!res.ok) { | ||
@@ -103,3 +91,3 @@ throw new Error(res.statusText); | ||
} | ||
fetchFromRadar(options = exports.defaultRadarOptions) { | ||
fetchFromRadar(options = config_1.defaultRadarOptions) { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j; | ||
@@ -160,3 +148,3 @@ return __awaiter(this, void 0, void 0, function* () { | ||
} | ||
fetchFromRadarMultiZone(zones, options = exports.defaultRadarOptions) { | ||
fetchFromRadarMultiZone(zones, options = config_1.defaultRadarOptions) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -163,0 +151,0 @@ const promises = []; |
{ | ||
"name": "flightradar24-client-ts", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A client for the Flightradar24 API written in TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
28546
16
664