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

strava-v3

Package Overview
Dependencies
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

strava-v3 - npm Package Compare versions

Comparing version 1.13.0 to 1.14.0

lib/runningRaces.js

2

index.js

@@ -18,2 +18,3 @@ /**

, uploads = require('./lib/uploads')
, runningRaces = require('./lib/runningRaces')
, routes = require('./lib/routes')

@@ -35,2 +36,3 @@ ;

strava.uploads = uploads;
strava.runningRaces = runningRaces;
strava.routes = routes;

@@ -37,0 +39,0 @@

28

lib/util.js

@@ -13,3 +13,4 @@ /**

var util = {};
util.rateLimit = 'x-ratelimit-limit';
util.rateUsage = 'x-ratelimit-usage';
util.endpointBase = 'https://www.strava.com/api/v3/';

@@ -215,7 +216,3 @@

request(options, function (err, response, payload) {
if (!err) {
//console.log(payload);
}
else {
if (err) {
console.log('api call error');

@@ -225,7 +222,24 @@ console.log(err);

done(err, payload);
done(err, payload, parseRateLimits(response.headers));
});
};
function parseRateLimits(headers) {
if(!headers[util.rateLimit] || !headers[util.rateUsage]) {
return null;
}
var limit = headers[util.rateLimit].split(',')
, usage = headers[util.rateUsage].split(',')
, radix = 10;
return {
shortTermUsage: parseInt(usage[0], radix),
shortTermLimit: parseInt(limit[0], radix),
longTermUsage: parseInt(usage[1], radix),
longTermLimit: parseInt(limit[1], radix)
};
}
//===== helpers =====
module.exports = util;
{
"name": "strava-v3",
"version": "1.13.0",
"version": "1.14.0",
"description": "Simple wrapper for strava v3 api",
"main": "index.js",
"scripts": {
"test": "grunt jshint simplemocha --force"
"test": "grunt jshint simplemocha"
},

@@ -9,0 +9,0 @@ "repository": {

@@ -24,2 +24,3 @@

* `gear`
* `running_races`
* `routes`

@@ -34,3 +35,3 @@ * `segments`

```bash
npm install strava-v3
npm install strava-v3
```

@@ -48,11 +49,11 @@

```js
var strava = require('strava-v3');
strava.athlete.get({},function(err,payload) {
if(!err) {
console.log(payload);
}
else {
console.log(err);
}
});
var strava = require('strava-v3');
strava.athlete.get({},function(err,payload,limits) {
if(!err) {
console.log(payload);
}
else {
console.log(err);
}
});
```

@@ -93,4 +94,4 @@

```js
var strava = require('strava-v3')
strava.<api endpoint>.<api endpoint option>(args,callback)
var strava = require('strava-v3')
strava.<api endpoint>.<api endpoint option>(args,callback)
```

@@ -101,6 +102,6 @@

```js
var strava = require('strava-v3');
strava.athletes.get({id:12345},function(err,payload) {
//do something with your payload
});
var strava = require('strava-v3');
strava.athletes.get({id:12345},function(err,payload,limits) {
//do something with your payload, track rate limits
});
```

@@ -117,6 +118,6 @@

```js
var strava = require('strava-v3');
strava.athlete.get({'access_token':'abcde'},function(err,payload) {
//do something with your payload
});
var strava = require('strava-v3');
strava.athlete.get({'access_token':'abcde'},function(err,payload,limits) {
//do something with your payload, track rate limits
});
```

@@ -131,9 +132,9 @@

```js
var strava = require('strava-v3');
strava.athlete.listFollowers({
'page':1
, 'per_page':2
},function(err,payload) {
//do something with your payload
});
var strava = require('strava-v3');
strava.athlete.listFollowers({
'page':1
, 'per_page':2
},function(err,payload,limits) {
//do something with your payload, track rate limits
});
```

@@ -147,15 +148,38 @@

```js
var strava = require('strava-v3');
strava.uploads.post({
'data_type':'gpx'
, 'file': 'data/your_file.gpx'
, 'name': 'Epic times'
, 'statusCallback': function(err,payload) {
//do something with your payload
}
},function(err,payload) {
//do something with your payload
});
var strava = require('strava-v3');
strava.uploads.post({
'data_type':'gpx'
, 'file': 'data/your_file.gpx'
, 'name': 'Epic times'
, 'statusCallback': function(err,payload) {
//do something with your payload
}
},function(err,payload,limits) {
//do something with your payload, track rate limits
});
```
### Rate limits
According to Strava's API each response contains information about rate limits.
For more details see: [Rate Limiting](https://strava.github.io/api/#rate-limiting)
Returns `null` if `X-Ratelimit-Limit` or `X-RateLimit-Usage` headers are not provided
```js
var strava = require('strava-v3');
strava.athlete.get({'access_token':'abcde'},function(err,payload,limits) {
//do something with your payload, track rate limits
console.log(limits);
/*
output:
{
shortTermUsage: 3,
shortTermLimit: 600,
longTermUsage: 12,
longTermLimit: 30000
}
*/
});
```
### Supported API Endpoints

@@ -216,2 +240,6 @@

Running Races:
* `strava.runningRaces.get(args,done)`
* `strava.runningRaces.listRaces(args,done)`
Routes:

@@ -253,5 +281,5 @@ * `strava.routes.get(args,done)`

```js
strava.oauth.getToken(code,function(err,payload) {
console.log(payload);
});
strava.oauth.getToken(code,function(err,payload,limits) {
console.log(payload);
});
```

@@ -258,0 +286,0 @@

@@ -11,6 +11,3 @@ /**

testsHelper.getSampleAthlete = function(done) {
strava.athlete.get({},function(err,payload) {
done(err,payload);
});
strava.athlete.get({},done);
};

@@ -64,2 +61,8 @@

testsHelper.getSampleRunningRace = function(done) {
strava.runningRaces.listRaces({'year': 2015},function(err,payload) {
done(err,payload[0]);
});
};
testsHelper.getAccessToken = function () {

@@ -66,0 +69,0 @@ try {

@@ -18,2 +18,3 @@

});
var originalToken = process.env.STRAVA_ACCESS_TOKEN;
delete process.env.STRAVA_ACCESS_TOKEN;

@@ -25,2 +26,3 @@ authenticator.purge();

mockFS.restore();
process.env.STRAVA_ACCESS_TOKEN = originalToken;
authenticator.purge();

@@ -33,4 +35,4 @@ });

});
var originalToken = process.env.STRAVA_ACCESS_TOKEN;
process.env.STRAVA_ACCESS_TOKEN = 'abcdefghi';
authenticator.purge();

@@ -41,4 +43,3 @@

mockFS.restore();
delete process.env.STRAVA_ACCESS_TOKEN;
process.env.STRAVA_ACCESS_TOKEN = originalToken;
authenticator.purge();

@@ -58,2 +59,3 @@ });

});
var originalClientId = process.env.STRAVA_CLIENT_ID;
delete process.env.STRAVA_CLIENT_ID;

@@ -65,2 +67,3 @@ authenticator.purge();

mockFS.restore();
process.env.STRAVA_CLIENT_ID = originalClientId
authenticator.purge();

@@ -73,4 +76,4 @@ });

});
var originalClientId = process.env.STRAVA_CLIENT_ID;
process.env.STRAVA_CLIENT_ID = 'abcdefghi';
authenticator.purge();

@@ -81,4 +84,3 @@

mockFS.restore();
delete process.env.STRAVA_CLIENT_ID;
process.env.STRAVA_CLIENT_ID = originalClientId;
authenticator.purge();

@@ -98,2 +100,3 @@ });

});
var originalClientSecret = process.env.STRAVA_CLIENT_SECRET;
delete process.env.STRAVA_CLIENT_SECRET;

@@ -105,2 +108,3 @@ authenticator.purge();

mockFS.restore();
process.env.STRAVA_CLIENT_SECRET = originalClientSecret;
authenticator.purge();

@@ -113,4 +117,4 @@ });

});
var originalClientSecret = process.env.STRAVA_CLIENT_SECRET;
process.env.STRAVA_CLIENT_SECRET = 'abcdefghi';
authenticator.purge();

@@ -121,4 +125,3 @@

mockFS.restore();
delete process.env.STRAVA_CLIENT_SECRET;
process.env.STRAVA_CLIENT_SECRET = originalClientSecret;
authenticator.purge();

@@ -138,2 +141,3 @@ });

});
var originalRedirectUri = process.env.STRAVA_REDIRECT_URI;
delete process.env.STRAVA_REDIRECT_URI;

@@ -145,2 +149,3 @@ authenticator.purge();

mockFS.restore();
process.env.STRAVA_REDIRECT_URI = originalRedirectUri;
authenticator.purge();

@@ -153,4 +158,4 @@ });

});
var originalRedirectUri = process.env.STRAVA_REDIRECT_URI;
process.env.STRAVA_REDIRECT_URI = 'https://sample.com';
authenticator.purge();

@@ -161,4 +166,3 @@

mockFS.restore();
delete process.env.STRAVA_REDIRECT_URI;
process.env.STRAVA_REDIRECT_URI = originalRedirectUri;
authenticator.purge();

@@ -165,0 +169,0 @@ });

@@ -38,2 +38,2 @@

});
});

@@ -41,2 +41,2 @@ /**

});
});

@@ -8,3 +8,3 @@

describe.skip('segments_test', function() {
describe('segments_test', function() {

@@ -11,0 +11,0 @@ before(function(done) {

Sorry, the diff of this file is not supported yet

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