mirror of
https://github.com/koodiklinikka/koodiklinikka.fi-api.git
synced 2026-01-26 03:34:03 +00:00
add amount parameter to service method
This commit is contained in:
@@ -12,8 +12,8 @@ module.exports = function (app) {
|
||||
*/
|
||||
app.get('/feeds', cache('3 hours'), function(req, res, next) {
|
||||
Promise.props({
|
||||
twitter: twitter.getTweets(),
|
||||
github: github.getEvents()
|
||||
twitter: twitter.getTweets(20),
|
||||
github: github.getEvents(20)
|
||||
}).then(function(data) {
|
||||
res.status(200).send(data);
|
||||
}, function(err) {
|
||||
|
||||
@@ -8,10 +8,10 @@ module.exports = {
|
||||
/**
|
||||
* Fetch five latest events from GitHub organization
|
||||
*/
|
||||
getEvents: function() {
|
||||
getEvents: function(amount) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
request
|
||||
.get('https://api.github.com/orgs/koodiklinikka/events?per_page=5')
|
||||
.get('https://api.github.com/orgs/koodiklinikka/events?per_page=' + amount)
|
||||
.set('Authorization', 'token ' + config.github.token)
|
||||
.end(function(error, response){
|
||||
if(error) {
|
||||
|
||||
@@ -15,9 +15,9 @@ module.exports = {
|
||||
/**
|
||||
* Fetch five latest tweets / retweets from Twitter
|
||||
*/
|
||||
getTweets: function() {
|
||||
getTweets: function(amount) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
twitterRestClient.statusesUserTimeline({count: 5}, function(error, result) {
|
||||
twitterRestClient.statusesUserTimeline({count: amount}, function(error, result) {
|
||||
if (error) {
|
||||
reject(error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user