mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-02-06 15:04:58 +00:00
Add aviation.js, Updatre http.js
This commit is contained in:
parent
2dae3a3abb
commit
c14f4358f3
85
lib/aviation.js
Normal file
85
lib/aviation.js
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
// aviation.js
|
||||||
|
// Namhyeon Go <abuse@catswords.net>
|
||||||
|
// https://github.com/gnh1201/welsonjs
|
||||||
|
//
|
||||||
|
// ***SECURITY NOTICE***
|
||||||
|
// Aviation Data Integration requires an internet connection, and data may be transmitted externally. Users must adhere to the terms of use and privacy policy.
|
||||||
|
// - AviationStack website: https://aviationstack.com/?utm_source=FirstPromoter&utm_medium=Affiliate&fpr=namhyeon71
|
||||||
|
//
|
||||||
|
var HTTP = require("lib/http");
|
||||||
|
|
||||||
|
var API_BASE_URL = "https://api.aviationstack.com/v1";
|
||||||
|
var API_ACCESS_KEY = "YOUR_ACCESS_KEY";
|
||||||
|
|
||||||
|
function getData(type, params, limit, offset) {
|
||||||
|
var params = params || {};
|
||||||
|
var limit = (function(n) {
|
||||||
|
return n > 0 ? n : 100;
|
||||||
|
}(parseInt(limit));
|
||||||
|
var offset = (function(n) {
|
||||||
|
return n > -1 ? n : 0;
|
||||||
|
}(parseInt(limit));
|
||||||
|
|
||||||
|
params["limit"] = limit;
|
||||||
|
params["offset"] = offset;
|
||||||
|
params["access_key"] = API_ACCESS_KEY;
|
||||||
|
|
||||||
|
var response = HTTP.create()
|
||||||
|
.setParameters(params)
|
||||||
|
.open("GET", API_BASE_URL + "/" + type)
|
||||||
|
.send();
|
||||||
|
|
||||||
|
return response.responseBody;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFlights(params, limit, offset) {
|
||||||
|
return getData("flights", params, limit, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRoutes(params, limit, offset) {
|
||||||
|
return getData("routes", params, limit, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAirports(params, limit, offset) {
|
||||||
|
return getData("airports", params, limit, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAirlines(params, limit, offset) {
|
||||||
|
return getData("airlines", params, limit, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getAircraftTypes(params, limit, offset) {
|
||||||
|
return getData("aircraft_types", params, limit, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCities(params, limit, offset) {
|
||||||
|
return getData("cities", params, limit, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCountries(params, limit, offset) {
|
||||||
|
return getData("countries", params, limit, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFlightSchedules(params, limit, offset) {
|
||||||
|
return getData("timetable", params, limit, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFlightsFuture(params, limit, offset) {
|
||||||
|
return getData("flightsFuture", params, limit, offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.getData = getData;
|
||||||
|
exports.getFlights = getFlights;
|
||||||
|
exports.getRoutes = getRoutes;
|
||||||
|
exports.getAirports = getAirports;
|
||||||
|
exports.getAirlines = getAirlines;
|
||||||
|
exports.getAircraftTypes = getAircraftTypes;
|
||||||
|
exports.getCities = getCities;
|
||||||
|
exports.getCountries = getCountries;
|
||||||
|
exports.getFlightSchedules = getFlightSchedules;
|
||||||
|
exports.getFlightsFuture = getFlightsFuture;
|
||||||
|
|
||||||
|
exports.VERSIONINFO = "Aviation Data Integration (aviation.js) version 0.1";
|
||||||
|
exports.AUTHOR = "abuse@catswords.net";
|
||||||
|
exports.global = global;
|
||||||
|
exports.require = global.require;
|
|
@ -39,14 +39,14 @@ var AVAILABLE_PROXIES = [
|
||||||
{
|
{
|
||||||
"type": "serp",
|
"type": "serp",
|
||||||
"provider": "librey",
|
"provider": "librey",
|
||||||
"url": "https://farside.link/librex/api.php?q={q}&p=1&t=0",
|
"url": "https://serp.catswords.net/librex/api.php?q={q}&p=1&t=0",
|
||||||
"documentation": "https://github.com/Ahwxorg/LibreY"
|
"documentation": "https://github.com/Ahwxorg/LibreY"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "serp",
|
"type": "serp",
|
||||||
"provider": "invidious",
|
"provider": "invidious",
|
||||||
"url": "https://farside.link/invidious/api/v1/search?q={q}",
|
"url": "https://invidious.jing.rocks/invidious/api/v1/search?q={q}",
|
||||||
"documentation": "https://docs.invidious.io/"
|
"documentation": "https://docs.invidious.io/instances/"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "stateless-jsonrpc2",
|
"type": "stateless-jsonrpc2",
|
||||||
|
@ -1323,7 +1323,7 @@ exports.parseURL = parseURL;
|
||||||
exports.DEFAULT_USER_AGENT = DEFAULT_USER_AGENT;
|
exports.DEFAULT_USER_AGENT = DEFAULT_USER_AGENT;
|
||||||
exports.defaultUserAgent = DEFAULT_USER_AGENT; // compatible
|
exports.defaultUserAgent = DEFAULT_USER_AGENT; // compatible
|
||||||
|
|
||||||
exports.VERSIONINFO = "HTTP Client for WelsonJS framework (http.js) version 0.7.43";
|
exports.VERSIONINFO = "HTTP Client for WelsonJS framework (http.js) version 0.7.44";
|
||||||
exports.AUTHOR = "abuse@catswords.net";
|
exports.AUTHOR = "abuse@catswords.net";
|
||||||
exports.global = global;
|
exports.global = global;
|
||||||
exports.require = global.require;
|
exports.require = global.require;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user