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

playlyfe-node-sdk

v0.2.3

Published

Playlyfe SDK for NodeJS

Downloads

5

Readme

Playlyfe Node SDK

Playlyfe API implementation in NodeJS. This module integrates seamlessly with the passport-playlyfe module for authentication support.

Visit the complete API reference

To learn more about how you can build applications on Playlyfe visit the official developer documentation

##Install To get started simply run

npm install playlyfe-node-sdk

##Synopsis

express = require('express');
Playlyfe = require('playlyfe-node-sdk')

// Put in your application details here.
var config = {
  type: 'code', // The type of OAuth2.0 flow we wish use
  client_id: 'YOUR CLIENT ID',
  client_secret: 'YOUR CLIENT SECRET',
  redirect_uri: 'https://localhost:8080/auth/redirect'
};

client = new Playlyfe(config);

app = express();
app.use(express.cookieParser());
app.use(express.session({ secret: 'TOP_SECRET' }));
app.use(express.static(__dirname+"/public"));
app.use(app.router);
app.use(express.logger());
app.use(express.errorHandler());

var auth = function (req, res, next) {
  if (req.session.logged_in) {
    return next();
  } else {
    return res.redirect(client.getAuthorizationURI());
  }
};

// start playlyfe oauth authorization code flow
app.get('/auth', auth, function (req, res) {
  return res.redirect('/home');
});

// get access token and save it
app.get('/auth/redirect', function (req, res) {
  if (req.query.code !== null) {
    client.getToken(req.query.code, function(err, token) {
      if (err) return res.json(500, err);
      req.session.auth = token;
      req.session.logged_in = true;
      res.redirect('/api/player');
    });
  } else {
    res.redirect('/api/player');
  }
});

// Proxy requests to playlyfe server.
// We keep the access token away from cheaters by using the authorization code flow.
app.all('/api/*', auth, function(req, res) {
  res.header("Cache-Control", "no-cache, no-store, must-revalidate");
  res.header("Pragma", "no-cache");
  res.header("Expires", 0);
  client.api(
    '/' + req.params[0],
    req.route.method.toUpperCase(),
    { qs: req.query, body: req.body },
    req.session.auth.token.access_token,
    function(err, response, body) {
      for (header in response.headers) {
        res.header(header, response.headers[header]);
      }
      res.end(body);
    }
  );
});

app.get('/logout', auth, function (req, res) {
  req.session.logged_in = false;
  delete req.session.auth;
  res.redirect('/');
});

app.listen(8080);

Methods

constructor (options)

The options object contains the configuration options for your playlyfe application. These values can be found in the clients menu in the game builder on the Playlyfe Platform.

{
  type: 'OAUTH_2.0_FLOW_TYPE' // Must be either code or client
  clientID: 'YOUR_CLIENT_ID',
  clientSecret: 'YOUR_CLIENT_SECRET',
  redirectURI: 'REDIRECT_URI' // Only required
}

The redirect URI must match exactly with any of the registered redirect endpoints or the oauth flow will fail.

getAuthorizationURI

Get the Authorization URI for the app.

getToken (code, saveTokenFunction)

Exchange the Authorization Code for Access Token.

api (url, method, data, access_token, callback)

Executes an API call. This method differs from the request helper in requiring the accessToken and refreshToken to be manually provided. Visit the complete API reference

License

Playlyfe NodeJS SDK v0.0.1
https://dev.playlyfe.com/
Copyright(c) 2013-2014, Playlyfe Technologies, [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.