npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dark-sky-skeleton

v0.1.46

Published

barebones dark sky weather api - for client or server-side js

Downloads

155

Readme

dark-sky-skeleton

Based on Elias Hussary's dark-sky.

A barebones isomorphic js 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.

You can use dark-sky-skeleton client-side OR server-side. Note: an example of a server side proxy used with client side dark-sky-skeleton is forthecoming...

Install it

 npm install dark-sky-skeleton

Import it

import DarkSkySkeleton from 'dark-sky-skeleton';

or Common JS

const DarkSkySkeleton = require('dark-sky-skeleton');

Initialize it

DarkSkySkeleton(apiKey, proxy)

  • {string|bool} apiKey - your Dark Sky api key or false if using proxy
  • {string|bool} [proxy] - optional URL to proxy service or true if running server-side

Client-side Setup

const api = new DarkSkySkeleton('your-dark-sky-api-key');

Proxy URL - Client-side be warned!

The above is simple and great for testing, but your api key is exposed in every request (when running in client-side). Using a separate server-side proxy to make the actual api call to dark sky is highly suggested as this hides the api key. [ref].

To use a proxy set your api-key to false or an empty string, and pass a URL to the proxy service as the proxy (second) param.

const api = new DarkSkySkeleton(false, '//base-url-to-proxy/service');
Experimental (help wanted)

dark-sky-skeleton theoretically supports a proxy service (aka untested). A proxy service would receive a request issued by dark-sky-skeleton, attach this query to a base URI (like the following: https://api.darksky.net/forecast/your-api-key), and return a final request.

Server Side Setup

const api = new DarkSkySkeleton('your-dark-sky-api-key', true);

Passing true as the proxy parameter indicates that the caller is server-side. Awesome!

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.:

darkSky.latitude(lat)
  .longitude(long)
  .get()
  .then(data => console.log(data));

darkSky.get().then(data => console.log(data));

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));