Fix indenting to 2 spaces, remove most lint errors

This commit is contained in:
Nathan Leniz
2015-03-22 20:20:08 +09:00
parent fb5e8dc387
commit 999ba14db7

View File

@ -28,8 +28,7 @@ exports.hotJSON = function(req, res) {
var story = Story.find({}).sort({'timePosted': -1}).limit(1000); var story = Story.find({}).sort({'timePosted': -1}).limit(1000);
story.exec(function(err, stories) { story.exec(function(err, stories) {
if (err) { if (err) {
res.send(500); return res.status(500);
return next(err);
} }
var foundationDate = 1413298800000; var foundationDate = 1413298800000;
@ -105,7 +104,7 @@ exports.preSubmit = function(req, res) {
var image = data.image || ''; var image = data.image || '';
var description = data.description || ''; var description = data.description || '';
return res.render('stories/index', { return res.render('stories/index', {
title: "Confirm your Camper News story submission", title: 'Confirm your Camper News story submission',
page: 'storySubmission', page: 'storySubmission',
storyURL: data.url, storyURL: data.url,
storyTitle: title, storyTitle: title,
@ -144,7 +143,7 @@ exports.returnIndividualStory = function(req, res, next) {
try { try {
var votedObj = story.upVotes.filter(function(a) { var votedObj = story.upVotes.filter(function(a) {
return a['upVotedByUsername'] === req.user['profile']['username']; return a['upVotedByUsername'] === req.user['profile']['username'];
}) });
if (votedObj.length > 0) { if (votedObj.length > 0) {
userVoted = true; userVoted = true;
} }
@ -171,9 +170,12 @@ exports.returnIndividualStory = function(req, res, next) {
exports.getStories = function(req, res) { exports.getStories = function(req, res) {
MongoClient.connect(secrets.db, function(err, database) { MongoClient.connect(secrets.db, function(err, database) {
if (err) {
return res.status(500);
}
database.collection('stories').find({ database.collection('stories').find({
"$text": { '$text': {
"$search": req.body.data.searchValue '$search': req.body.data.searchValue
} }
}, { }, {
headline: 1, headline: 1,
@ -188,15 +190,18 @@ exports.getStories = function(req, res) {
storyLink: 1, storyLink: 1,
metaDescription: 1, metaDescription: 1,
textScore: { textScore: {
$meta: "textScore" $meta: 'textScore'
} }
}, { }, {
sort: { sort: {
textScore: { textScore: {
$meta: "textScore" $meta: 'textScore'
} }
} }
}).toArray(function(err, items) { }).toArray(function(err, items) {
if (err) {
return res.status(500);
}
if (items !== null && items.length !== 0) { if (items !== null && items.length !== 0) {
return res.json(items); return res.json(items);
} }