Socket
Socket
Sign inDemoInstall

dark-sky-skeleton

Package Overview
Dependencies
5
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    dark-sky-skeleton

barebones dark sky weather api for client side js - supports api key and proxy urls


Version published
Maintainers
1
Install size
62.4 kB
Created

Readme

Source

dark-sky-skeleton

Based on Elias Hussary's dark-sky.

A barebones wrapper library for Dark Sky API (previously known as Forecast.io). See Dark Sky developer docs: https://darksky.net/dev/docs.

For a more robust solution see dark-sky-api.

Install it

 npm install dark-sky-skeleton

Require it

import darkSkySkeleton from 'dark-sky-skeleton';

Initialize it

While dark-sky-skeleton allows embedding api keys through use of jsonp on the backend using a proxy to make the api call is highly suggested as this hides the API key from client side requests [ref].

  • proxy url is optional
  • pass an empty string or false for api key if using proxy url
const darkSky = new darkSkySkeleton('your-dark-sky-api-key', '//base-url-to-proxy/service');

Use it

darkSky.latitude(lat)
  .longitude(long)
  .units('us')
  .language('en')
  .time('2000-04-06T12:20:05') // moment().year(2000).format('YYYY-MM-DDTHH:mm:ss')
  .extendHourly(true)
  .get();
  .then(data => console.log(data));

Feel free to omit setting of latitude and longitude for subsequent calls i.e.:

const darkSky = new darkSkyApi('your-dark-sky-api-key');
darkSky.latitude(lat)
  .longitude(long);

darkSky.get();

Make use of excludes

"Exclude some number of data blocks from the API response. This is useful for reducing latency and saving cache space (see 'Request Parameters')."

const excludes = ['alerts', 'currently', 'daily', 'flags', 'hourly', 'minutely'],
  exludesBlock = excludes.filter(val => val != 'currently').join(',')
darkSky.latitude(lat)
  .longitude(long)
  .exclude(excludesBlock)
  .get()
  .then(data => console.log(data));

TODO

  • reset query params when appropriate
  • add testing

Keywords

FAQs

Last updated on 27 Jun 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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