Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

singly

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

singly - npm Package Compare versions

Comparing version 0.0.0 to 0.0.1

37

lib.js

@@ -5,2 +5,3 @@ var request = require('request');

var apiBaseUrl = 'https://api.singly.com';
var API_VERSION = 0;

@@ -10,6 +11,7 @@ module.exports = function(clientId, clientSecret, redirectURI) {

client.getAuthorizeURL = function(service) {
client.getAuthorizeURL = function(service, callbackURLOverride) {
var cbURL = callbackURLOverride || redirectURI;
return apiBaseUrl + '/oauth/authorize?' + querystring.stringify({
client_id: clientId,
redirect_uri: redirectURI,
redirect_uri: cbURL,
service: service

@@ -43,3 +45,32 @@ });

// build a consistent and clean URI
function getURI(path) {
var uri = apiBaseUrl;
if (path.indexOf(/\/?v[0-9]/) !== 0) uri += '/v' + API_VERSION
if (path.indexOf('/') !== 0) uri += '/';
return uri + path;
}
function setupAPICall(options) {
if (options.access_token && !(options.qs && options.qs.access_token)) {
if (!options.qs) options.qs = {};
options.qs.access_token = options.access_token;
}
}
client.post = function(path, options, callback) {
var uri = getURI(path);
setupAPICall(options);
request.post({uri:uri, json:options.body, qs:options.qs}, callback);
}
client.get = function(path, options, callback) {
var uri = getURI(path);
setupAPICall(options);
request.get({uri:uri, json:true, qs:options.qs}, callback);
}
client.apiCall = function(path, params, callback) {
console.warn('singly.apiCall is deprecated and will be removed in future verions. ' +
'Please use singly.get and singly.post.');
var uri = apiBaseUrl + path + '?' + querystring.stringify(params);

@@ -52,2 +83,2 @@ request.get({uri:uri, json:true}, function(err, resp, json) {

return client;
}
}

2

package.json

@@ -5,3 +5,3 @@ {

"description": "Client library for the Singly API",
"version": "0.0.0",
"version": "0.0.1",
"homepage": "http://dev.singly.com",

@@ -8,0 +8,0 @@ "main" : "lib.js",

@@ -26,9 +26,19 @@ var Singly = require('./lib');

if (!accessToken) return res.redirect('/');
singly.apiCall('/types/all', {access_token:accessToken}, function(err, resp) {
singly.get('/types/all', {access_token:accessToken}, function(err, resp, body) {
if(err) return res.send(err, 500);
res.send(resp);
res.send(body);
});
});
app.post('/status', function(req, res) {
if (!accessToken) return res.send('must auth at http://localhost:8044/', 401);
var qs = req.query;
qs.access_token = accessToken;
singly.post('/types/statuses', {qs:req.query}, function(err, resp, body) {
if (err) return res.send(err, 500);
res.send(body);
});
});
app.listen(8044);
console.log('open http://localhost:8044');
console.log('open http://localhost:8044');
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