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

guardian-api

v0.0.1

Published

Provides access to Bungie's API with OAuth2 functionality

Downloads

3

Readme

Guardian API

Simplified access to Bungie's Destiny API including OAuth.

Example Usage

'use strict';

var bungie = require('../guardian-api');
var express = require('express');
var fs = require('fs');
var sqlite3 = require('sqlite3').verbose();
var https = require('https');
var querystring = require('querystring');
var db = new sqlite3.Database(':memory:');
var events = require('events');

var app = express();

// Tell Guardian API what our API key is was well as our app id.
// The app id is used to generate the authroziation URL
bungie.setApiKey('9b9d966677e44029b28da69312b960ed');
bungie.setAppID('10767');

// When Guardian API receives new token data, either initially or
// when it has refreshed the tokens because the access token expired
// this function will be called. You can store the info and when the 
// visitor returns set the token data from the stored info saving you
// the authorization step
var tokenDataArrived = function(data) {
  // handle new token data arriving, or don't
  console.log(data);
}

bungie.setNewTokenCallback(tokenDataArrived);

app.get('/', function(req, res) {
  if (!bungie.isAuthorized()) {
    bungie.authorize(res);
  }
  else {
    bungie.getBungieNetUser(function(data) {
      res.send(data);
    });
  }
  
});

app.get('/refresh', function(req, res) {
  bungie.refresh(function(data) {
    console.log("refreshed token");
  });
  res.send("requested token refresh");
});

app.get('/code', function(req, res) {
  var state;
  bungie.parseCode(req.url, state, function(data) {
    
    if (Object.keys(data).length > 0) {
      res.redirect(302, '/');
    }
    else {
      res.redirect(302, '/authorization-failure')
    }
  });
});

app.get('/authorization-failure', function(req, res) {
  res.send("Something went wrong, maybe they denied?");
});


https.createServer({
  key: fs.readFileSync('ssl/key.pem'),
  cert: fs.readFileSync('ssl/cert.pem')
}, app).listen(3000, function() {
  
  
  console.log("Ready on port 3000");
});