Last active
March 3, 2017 15:56
-
-
Save acatl/3db98f837658b50ce37e6a62ca37c185 to your computer and use it in GitHub Desktop.
get trending example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports = { | |
'source:getTrending': { | |
url: 'http://api.giphy.com/v1/gifs/feqkVgjJpYtjy?api_key=dc6zaTOxFJmzC' | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const valuesIn = (ctx, done) => { | |
done(null, _.valuesIn(ctx.value)); | |
}; | |
const pick = (keys) => (ctx, done) => { | |
done(null, _.pick(ctx.value, keys)); | |
}; | |
exports = { | |
'source:getTrending': { | |
url: 'http://api.giphy.com/v1/gifs/trending?api_key=dc6zaTOxFJmzC' | |
}, | |
'model:Trending': { | |
before: 'source:getTrending', | |
context: '$data', | |
map: 'model:Post' | |
}, | |
'model:Post': { | |
extend: { | |
user: '$user | model:User', | |
images: ['$images', pick(['original']), valuesIn, 'model:PostImages'] | |
}, | |
omit: ['username'] | |
}, | |
'model:User': { | |
pick: ['username', 'display_name'] | |
}, | |
'model:PostImages': { | |
pick: ['url', 'width', 'height'] | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment