mirror of
https://github.com/koodiklinikka/koodiklinikka.fi-api.git
synced 2026-03-18 12:05:31 +00:00
Changed feeds endpoint to use Promise.props to make the result more reasonable to work with
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
"bluebird": "^2.9.3",
|
"bluebird": "^2.9.3",
|
||||||
"body-parser": "^1.10.1",
|
"body-parser": "^1.10.1",
|
||||||
"express": "^4.11.0",
|
"express": "^4.11.0",
|
||||||
"lodash": "^2.4.1",
|
"lodash": "3.0.0",
|
||||||
"node-twitter": "0.5.2",
|
"node-twitter": "0.5.2",
|
||||||
"superagent": "^0.21.0",
|
"superagent": "^0.21.0",
|
||||||
"validator": "^3.27.0"
|
"validator": "^3.27.0"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
var request = require('superagent');
|
var request = require('superagent');
|
||||||
var cache = require('apicache').middleware;
|
var cache = require('apicache').middleware;
|
||||||
|
var Promise = require('bluebird');
|
||||||
var twitter = require('../feeds/twitter');
|
var twitter = require('../feeds/twitter');
|
||||||
var github = require('../feeds/github');
|
var github = require('../feeds/github');
|
||||||
|
|
||||||
@@ -11,7 +12,10 @@ module.exports = function (app) {
|
|||||||
* Endpoint for fetching different information feeds (Twitter, GitHub etc.)
|
* Endpoint for fetching different information feeds (Twitter, GitHub etc.)
|
||||||
*/
|
*/
|
||||||
app.get('/feeds', cache('3 hours'), function(req, res, next) {
|
app.get('/feeds', cache('3 hours'), function(req, res, next) {
|
||||||
Promise.all([twitter.getTweets(), github.getEvents()]).then(function(data) {
|
Promise.props({
|
||||||
|
twitter: twitter.getTweets(),
|
||||||
|
github: github.getEvents()
|
||||||
|
}).then(function(data) {
|
||||||
res.status(200).send(data);
|
res.status(200).send(data);
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
next(err);
|
next(err);
|
||||||
|
|||||||
Reference in New Issue
Block a user