Socket
Socket
Sign inDemoInstall

ksoft.js

Package Overview
Dependencies
118
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.1 to 1.2.2

230

lib/apis/kumo.js

@@ -8,3 +8,3 @@ /**

* @prop {String} map The map of the location
*
*
* @typedef {Object} searchResponse the response for kumo.search (may not be exact due to option differences)

@@ -14,6 +14,6 @@ * @prop {Boolean} error Whether there was an error or not

* @prop {gisData} data The data for this location
*
*
* @typedef getSimpleWeatherAlerts
* @prop {String} title The title of the alert
* @prop {Array<Strings>} regions The regions the alert is for
* @prop {Array<Strings>} regions The regions the alert is for
* @prop {String} severity The severity of the alert

@@ -24,3 +24,3 @@ * @prop {Number} time The epoch time of the alert

* @prop {String} uri The uri of the alert
*
*
* @typedef {Object} getSimpleWeatherData data object for getSimpleWeather

@@ -48,7 +48,7 @@ * @prop {String} time The time of the last update

* @prop {Array<getSimpleWeatherAlerts>} alerts alerts
*
*
* @typedef location the location specified
* @prop {Number} lat The latitude of the location
* @prop {Number} lat The latitude of the location
* @prop {Number} lon The longitude of the location
*
*
* @typedef {Object} getSimpleWeatherResponse The response for kumo.getSimpleWeather (may not be exact due to option differences)

@@ -60,6 +60,6 @@ * @prop {Boolean} error If there was an error or not

* @prop {location} location The location shown
*
*
* @typedef getAdvancedWeatherAlerts
* @prop {String} title The title of the alert
* @prop {Array<Strings>} regions The regions the alert is for
* @prop {Array<Strings>} regions The regions the alert is for
* @prop {String} severity The severity of the alert

@@ -70,3 +70,3 @@ * @prop {Number} time The epoch time of the alert

* @prop {String} uri The uri of the alert
*
*
* @typedef {Object} getAdvancedWeatherData data object for getSimpleWeather

@@ -94,3 +94,3 @@ * @prop {String} time The time of the last update

* @prop {Array<getAdvancedWeatherAlerts>} alerts alerts
*
*
* @typedef {Object} getAdvancedWeatherResponse The response for kumo.getSimpleWeather (may not be exact due to option differences)

@@ -102,3 +102,3 @@ * @prop {Boolean} error If there was an error or not

* @prop {location} location The location shown
*
*
* @typedef {Object} apis The apis you can use in geoip

@@ -109,3 +109,3 @@ * @prop {String} weather the api url you can use to get the weather data about the location

* @prop {String} googlemaps google maps url
*
*
* @typedef {Object} geoipData The data for geoipResponse

@@ -123,4 +123,4 @@ * @prop {String} city The city that the ip comes back to

* @prop {String} time_zone The timezone the ip comes back to
* @prop {apis} apis api's you can use to get more information about the location
*
* @prop {apis} apis api's you can use to get more information about the location
*
* @typedef {Object} geoipResponse The response for kumo.geoip

@@ -130,3 +130,3 @@ * @prop {Boolean} error Whether or not there was an error

* @prop {geoipData} data The data object for geoip data
*
*
* @typedef {Object} convertCurrencyResponse The response for kumo.convertCurrency

@@ -136,99 +136,107 @@ * @prop {Number} value The value in the convert to type parameter

*/
const axios = require('axios')
const axios = require('axios');
let kumo = class kumo {
constructor(token){
this.token = token
this.http = axios.create({
baseURL: 'https://api.ksoft.si',
timeout: 2000,
headers: {'Authorization': `NANI ${this.token}`}
})
}
/**
* @param {String} q The query for the location you want data for
* @param {Boolean} fast Default: fast, return location data faster, but with less information
* @param {Boolean} more return more than one location
* @param {Number} mapZoom Default: 12, set your own zoom level, if fast is not set or false, then this setting will be ignored because map zoom is calculated
* @param {Boolean} includeMap Default: false, if to include an image of the area
* @returns {Promise<searchResponse>} Information for the location
*/
async search(q, {fast,more,mapZoom,includeMap}){
if(!q) throw new Error("[Ksoft API] Please define a search query")
const params = { q };
if (fast) params.fast = fast;
if (more) params.more = more
if (mapZoom) params.map_zoom = mapZoom;
if (includeMap) params.include_map = includeMap;
const { data } = await this.http.get(`/kumo/gis?${require('querystring').stringify(params)}`)
return data
}
/**
* @param {String} reportType weather report type. Can be one of: "currently", "minutely", "hourly", "daily"
* @param {String} q Location search query
* @param {String} units Unit types you can select on of: "si", "us", "uk2", "ca", "auto"
* @param {String} lang The language of the response: 'ar', 'az', 'be', 'bg', 'bs', 'ca', 'cs', 'da', 'de', 'el', 'en', 'es', 'et', 'fi', 'fr', 'he', 'hr', 'hu', 'id', 'is', 'it', 'ja', 'ka', 'ko', 'kw', 'nb', 'nl', 'no', 'pl', 'pt', 'ro', 'ru', 'sk', 'sl', 'sr', 'sv', 'tet', 'tr', 'uk', 'x-pig-latin', 'zh', 'zh-tw'
* @param {String} icons Default: original, select icon pack
* @returns {Promise<getSimpleWeatherResponse>} The information about the weather
*/
async getSimpleWeather(reportType,q,units,lang,icons){
let reportTypes = ["currently", "minutely", "hourly", "daily"]
if(!reportType) throw new Error(`[Ksoft API] Please define a report type. Types: ${reportTypes.join(" , ")}`)
if(!q) throw new Error("[Ksoft API] Please define a search query")
const params = { q };
if (units) params.units = units;
if (lang) params.lang = lang;
if (icons) params.icons = icons;
const { data } = await this.http.get(`/kumo/weather/${reportType}?${require('querystring').stringify(params)}`)
return data
}
/**
* @param {Number} latitude The latitude of the location you are getting weather for
* @param {Number} longitude The longitude of the location you are getting weather for
* @param {String} reportType weather report type. Can be one of: "currently", "minutely", "hourly", "daily"
* @param {String} units Unit types you can select on of: "si", "us", "uk2", "ca", "auto"
* @param {String} lang The language of the response: 'ar', 'az', 'be', 'bg', 'bs', 'ca', 'cs', 'da', 'de', 'el', 'en', 'es', 'et', 'fi', 'fr', 'he', 'hr', 'hu', 'id', 'is', 'it', 'ja', 'ka', 'ko', 'kw', 'nb', 'nl', 'no', 'pl', 'pt', 'ro', 'ru', 'sk', 'sl', 'sr', 'sv', 'tet', 'tr', 'uk', 'x-pig-latin', 'zh', 'zh-tw'
* @param {String} icons Default: original, select icon pack
* @returns {Promise<getAdvancedWeatherResponse>} The information about the weather
*/
async _getAdvancedWeather(latitude,longitude,reportType,units,lang,icons){
let reportTypes = ["currently", "minutely", "hourly", "daily"]
if(!reportType) throw new Error(`[Ksoft API] Please define a report type. Types: ${reportTypes.join(" , ")}`)
if(!latitude) throw new Error("[Ksoft API] please provide a latitude for the location")
if(!longitude) throw new Error("[Ksoft API] please provide a longitude for the location")
const urlParams = [latitude,longitude,reportType]
const params = {};
if (units) params.units = units;
if (lang) params.lang = lang;
if (icons) params.icons = icons;
const { data } = await this.http.get(`/kumo/weather/${urlParams.splice(0,2).join(",")}/${urlParams.pop()}?${require('querystring').stringify(params)}').stringify(params)}`)
return data
}
/**
* @param {String} ip the ip address that you want to get information from
* @returns {Promise<geoipResponse>} Information about the ip
*/
async geoip(ip){
if(!ip) throw new Error("[Ksoft API] Please define an ip address")
const { data } = await this.http.get(`/kumo/geoip?ip=${ip}`)
return data
}
/**
*
* @param {String} from The currency type to convert from
* @param {String} to The currency type to convert to
* @param {Number} value The currency amount to convert
* @returns {Promise<convertCurrencyResponse>} converted currency
*/
async convertCurrency(from,to,value){
if(!from) throw new Error("[Ksoft API] Please define a currency type to convert from")
if(!to) throw new Error("[Ksoft API] Please define a currency type to convert to")
if(!value) throw new Error("[Ksoft API] Please define an amount to convert")
const { data } = await this.http.get(`/kumo/currency?from=${from}&to=${to}&value=${value}`)
return data
}
}
constructor(token) {
this.token = token;
this.http = axios.create({
baseURL: 'https://api.ksoft.si',
timeout: 2000,
headers: { Authorization: `NANI ${this.token}` },
});
this.cache = new Map();
}
/**
* @param {String} q The query for the location you want data for
* @param {Boolean} fast Default: fast, return location data faster, but with less information
* @param {Boolean} more return more than one location
* @param {Number} mapZoom Default: 12, set your own zoom level, if fast is not set or false, then this setting will be ignored because map zoom is calculated
* @param {Boolean} includeMap Default: false, if to include an image of the area
* @returns {Promise<searchResponse>} Information for the location
*/
async search(q, { fast, more, mapZoom, includeMap }) {
if (!q) throw new Error('[Ksoft API] Please define a search query');
const params = { q };
if (fast) params.fast = fast;
if (more) params.more = more;
if (mapZoom) params.map_zoom = mapZoom;
if (includeMap) params.include_map = includeMap;
const { data } = await this.http.get(`/kumo/gis?${require('querystring').stringify(params)}`);
return data;
}
/**
* @param {String} reportType weather report type. Can be one of: "currently", "minutely", "hourly", "daily"
* @param {String} q Location search query
* @param {String} units Unit types you can select on of: "si", "us", "uk2", "ca", "auto"
* @param {String} lang The language of the response: 'ar', 'az', 'be', 'bg', 'bs', 'ca', 'cs', 'da', 'de', 'el', 'en', 'es', 'et', 'fi', 'fr', 'he', 'hr', 'hu', 'id', 'is', 'it', 'ja', 'ka', 'ko', 'kw', 'nb', 'nl', 'no', 'pl', 'pt', 'ro', 'ru', 'sk', 'sl', 'sr', 'sv', 'tet', 'tr', 'uk', 'x-pig-latin', 'zh', 'zh-tw'
* @param {String} icons Default: original, select icon pack
* @returns {Promise<getSimpleWeatherResponse>} The information about the weather
*/
async getSimpleWeather(reportType, q, units, lang, icons) {
let reportTypes = ['currently', 'minutely', 'hourly', 'daily'];
if (!reportType) throw new Error(`[Ksoft API] Please define a report type. Types: ${reportTypes.join(' , ')}`);
if (!q) throw new Error('[Ksoft API] Please define a search query');
const params = { q };
if (units) params.units = units;
if (lang) params.lang = lang;
if (icons) params.icons = icons;
const { data } = await this.http.get(`/kumo/weather/${reportType}?${require('querystring').stringify(params)}`);
return data;
}
/**
* @param {Number} latitude The latitude of the location you are getting weather for
* @param {Number} longitude The longitude of the location you are getting weather for
* @param {String} reportType weather report type. Can be one of: "currently", "minutely", "hourly", "daily"
* @param {String} units Unit types you can select on of: "si", "us", "uk2", "ca", "auto"
* @param {String} lang The language of the response: 'ar', 'az', 'be', 'bg', 'bs', 'ca', 'cs', 'da', 'de', 'el', 'en', 'es', 'et', 'fi', 'fr', 'he', 'hr', 'hu', 'id', 'is', 'it', 'ja', 'ka', 'ko', 'kw', 'nb', 'nl', 'no', 'pl', 'pt', 'ro', 'ru', 'sk', 'sl', 'sr', 'sv', 'tet', 'tr', 'uk', 'x-pig-latin', 'zh', 'zh-tw'
* @param {String} icons Default: original, select icon pack
* @returns {Promise<getAdvancedWeatherResponse>} The information about the weather
*/
async _getAdvancedWeather(latitude, longitude, reportType, units, lang, icons) {
let reportTypes = ['currently', 'minutely', 'hourly', 'daily'];
if (!reportType) throw new Error(`[Ksoft API] Please define a report type. Types: ${reportTypes.join(' , ')}`);
if (!latitude) throw new Error('[Ksoft API] please provide a latitude for the location');
if (!longitude) throw new Error('[Ksoft API] please provide a longitude for the location');
const urlParams = [latitude, longitude, reportType];
const params = {};
if (units) params.units = units;
if (lang) params.lang = lang;
if (icons) params.icons = icons;
const { data } = await this.http.get(
`/kumo/weather/${urlParams.splice(0, 2).join(',')}/${urlParams.pop()}?${require('querystring').stringify(
params
)}').stringify(params)}`
);
return data;
}
/**
* @param {String} ip the ip address that you want to get information from
* @returns {Promise<geoipResponse>} Information about the ip
*/
async geoip(ip) {
if (!ip) throw new Error('[Ksoft API] Please define an ip address');
if (this.cache.has(ip)) return this.cache.get(ip);
const { data } = await this.http.get(`/kumo/geoip?ip=${ip}`);
this.cache.set(ip, data);
return data;
}
/**
*
* @param {String} from The currency type to convert from
* @param {String} to The currency type to convert to
* @param {Number} value The currency amount to convert
* @returns {Promise<convertCurrencyResponse>} converted currency
*/
async convertCurrency(from, to, value) {
if (!from) throw new Error('[Ksoft API] Please define a currency type to convert from');
if (!to) throw new Error('[Ksoft API] Please define a currency type to convert to');
if (!value) throw new Error('[Ksoft API] Please define an amount to convert');
if (this.cache.has(`${from} ${to} ${value}`)) return this.cache.get(`${from} ${to} ${value}`);
const { data } = await this.http.get(`/kumo/currency?from=${from}&to=${to}&value=${value}`);
this.cache.set(`${from} ${to} ${value}`, data);
return data;
}
};
module.exports = {
kumo
}
kumo,
};

@@ -83,2 +83,3 @@ /**

});
this.cache = new Map();
}

@@ -92,2 +93,4 @@ /**

if (!q) throw new Error('[Ksoft API] Please define a search query');
if (this.cache.has(q)) return this.cache.get(q);
const params = {};

@@ -104,2 +107,3 @@ const query = q;

const { data } = await this.http.get(`/lyrics/search?q="${query}"&${require('querystring').stringify(params)}`);
this.cache.set(q, data);
return data;

@@ -113,3 +117,5 @@ }

if (!id) throw new Error('[Ksoft API] Please define an id');
if (this.cache.has(id)) return this.cache.get(id);
const { data } = await this.http.get(`/lyrics/artist/${id}/`);
this.cache.set(id, data);
return data;

@@ -123,3 +129,5 @@ }

if (!id) throw new Error('[Ksoft API] Please define an id');
if (this.cache.has(id)) return this.cache.get(id);
const { data } = await this.http.get(`/lyrics/album/${id}/`);
this.cache.set(id, data);
return data;

@@ -133,3 +141,5 @@ }

if (!id) throw new Error('[Ksoft API] Please define an id');
if (this.cache.has(id)) return this.cache.get(id);
const { data } = await this.http.get(`/lyrics/track/${id}/`);
this.cache.set(id, data);
return data;

@@ -147,2 +157,17 @@ }

let ytdl = null;
if (this.cache.has(query)) {
const response = this.cache.get(query);
if (voiceChannelConnection) {
try {
ytdl = require('ytdl-core');
} catch (e) {
throw new Error('ytdl-core is required for playing music');
}
(voiceChannelConnection.playStream || voiceChannelConnection.play)(
ytdl(youtubeResult[0].url, { filter: 'audioonly' })
);
}
return response;
}
try {

@@ -149,0 +174,0 @@ ytdl = require('ytdl-core');

{
"name": "ksoft.js",
"version": "1.2.1",
"version": "1.2.2",
"description": "Official API Wrapper for KSoft.Si API, written in Node.js",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc