Vulcan/server/api.js
Christian Bundy 86ec3ede93 Solve trivial JS errors
Using jshint and and fixmyjs I went through and removed 220 trivial
Javascript errors – mostly missing semicolons, and some properties that
weren’t written in dot notation. You can view the diff of jshint’s
output here:
https://gist.github.com/christianbundy/7b37c51bb6f7c8d739e7/revisions
2014-05-06 20:15:48 -07:00

31 lines
No EOL
768 B
JavaScript

serveAPI = function(limitSegment){
var posts = [];
var limit = 100; // default limit: 100 posts
if(typeof limitSegment !== 'undefined')
limit = limitSegment;
Posts.find({status: STATUS_APPROVED}, {sort: {submitted: -1}, limit: limit}).forEach(function(post) {
var url = (post.url ? post.url : getPostUrl(post._id));
var properties = {
headline: post.headline,
author: post.author,
date: post.submitted,
url: url,
guid: post._id
};
if(post.body)
properties.body = post.body;
if(post.url)
properties.domain = getDomain(url);
if(twitterName = getTwitterNameById(post.userId))
properties.twitterName = twitterName;
posts.push(properties);
});
return JSON.stringify(posts);
};