New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

theweatherapi

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

theweatherapi - npm Package Compare versions

Comparing version 2.1.4 to 2.2.0

2

package.json
{
"name": "theweatherapi",
"version": "2.1.4",
"version": "2.2.0",
"description": "An NPM Library used to get weather info",

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

@@ -52,3 +52,3 @@ const { EventEmitter } = require('events');

*/
this.api = new RequestHandler();
this.api = RequestHandler;

@@ -55,0 +55,0 @@ }

@@ -28,6 +28,6 @@ const apiTypes = require('./api-types.json');

Util.verifyString(endpoint1, 'Endpoint must be a string');
const endpoints = ['search', 'forecast', 'current'];
const endpoints = ['search', 'forecast', 'current', 'history', 'timezone', 'sports', 'ip', 'astronomy'];
if (!endpoints.includes(endpoint1)) {throw new RangeError('UKNOWN_API_ENDPOINT');}
const formats = ['json', 'xml'];
if (!formats.includes(format.toLowerCase())) {throw new TypeError('INVALID_FORMAT')}
if (!formats.includes(format.toLowerCase())) {throw new TypeError('UNKNOWN_FORMAT')}

@@ -56,4 +56,8 @@ this.baseURL += `${endpoint1}.${format.toLowerCase()}`

const reponse = await axios.get(baseUrl)
.catch(error => RequestHandler.handleError(error));
const reponse = await axios.get(this.baseURL)
.catch(error => {
const WeatherAPIError = require('../WeatherAPIError');
if (error.response.status === 404) throw new WeatherError('UKNOWN_API_ENDPOINT');
throw new WeatherAPIError(error.response.data, error.response.config);
});
return reponse;

@@ -60,0 +64,0 @@

@@ -14,51 +14,51 @@ const CurrentAPI = require('./api/CurrentAPI');

class RequestHandler {
constructor() {
/**
* The Search API
* @type {SearchAPI}
*/
this.search = new SearchAPI();
/**
* The Search API
* @type {SearchAPI}
*/
static search = new SearchAPI();
/**
* The Forecast API
* @type {ForecastAPI}
*/
this.forecast = new ForecastAPI();
/**
* The Forecast API
* @type {ForecastAPI}
*/
static forecast = new ForecastAPI();
/**
* The Current API
* @type {CurrentAPI}
*/
this.current = new CurrentAPI();
/**
* The Current API
* @type {CurrentAPI}
*/
static current = new CurrentAPI();
/**
* The Current API
* @type {AstronomyAPI}
*/
this.astronomy = new AstronomyAPI();
/**
* The Current API
* @type {AstronomyAPI}
*/
static astronomy = new AstronomyAPI();
/**
* The Current API
* @type {SportsAPI}
*/
this.sports = new SportsAPI();
/**
* The Current API
* @type {SportsAPI}
*/
static sports = new SportsAPI();
/**
* The Current API
* @type {HistoryAPI}
*/
this.history = new HistoryAPI();
/**
* The Current API
* @type {HistoryAPI}
*/
static history = new HistoryAPI();
/**
* The Current API
* @type {TimezoneAPI}
*/
this.timezone = new TimezoneAPI();
/**
* The Current API
* @type {TimezoneAPI}
*/
static timezone = new TimezoneAPI();
/**
* The Current API
* @type {IPAPI}
*/
this.ip = new IPAPI();
}
/**
* The Current API
* @type {IPAPI}
*/
static ip = new IPAPI();

@@ -70,3 +70,3 @@ /**

*/
async makeRequest(request) {
static async makeRequest(request) {
const axios = require('axios');

@@ -121,3 +121,3 @@ const Util = require('../Utils/Util');

*/
handleError(error) {
static handleError(error) {
const WeatherAPIError = require('./WeatherAPIError');

@@ -137,3 +137,3 @@ const { TypeError, WeatherError, RangeError } = require('../errors');

*/
createRequestObj(path, method, parameters = [], key) {
static createRequestObj(path, method, parameters = [], key) {
return {

@@ -140,0 +140,0 @@ path,

@@ -77,14 +77,13 @@ import {

export class RequestHandler {
public constructor();
public forecast: ForecastAPI;
public current: CurrentAPI;
public timezone: TimezoneAPI;
public history: HistoryAPI;
public astronomy: AstronomyAPI;
public search: SearchAPI;
public ip: IPAPI;
public sports: SportsAPI;
public makeRequest(request: object): Promise<object>
public handleError(error: Error): WeatherAPIError
public createRequestObj(path: string, method: string, parameters: Array<string>, key: apiKey): object
public static forecast: ForecastAPI;
public static current: CurrentAPI;
public static timezone: TimezoneAPI;
public static history: HistoryAPI;
public static astronomy: AstronomyAPI;
public static search: SearchAPI;
public static ip: IPAPI;
public static sports: SportsAPI;
public static makeRequest(request: object): Promise<object>
public static handleError(error: Error): WeatherAPIError
public static createRequestObj(path: string, method: string, parameters: Array<string>, key: apiKey): object

@@ -91,0 +90,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc