Skip to content

Commit

Permalink
lint(app): mainly fix indents in mongoose schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Delapouite committed Nov 17, 2015
1 parent b6494d0 commit 9a43cb9
Show file tree
Hide file tree
Showing 5 changed files with 381 additions and 354 deletions.
24 changes: 24 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"rules": {
"indent": [
2,
"tab"
],
"quotes": [
2,
"single"
],
"linebreak-style": [
2,
"unix"
],
"semi": [
2,
"always"
]
},
"env": {
"node": true
},
"extends": "eslint:recommended"
}
41 changes: 20 additions & 21 deletions app/gameserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ var User = require('./models/user');
//TODO: make sure that all items (current game, friends, etc) are kept in sync, consider just sending user and updating every time the user changes
var userToSocket = {};

var smtpTransport = nodemailer.createTransport("SMTP",{
service: "Gmail",
auth: {
user: "[email protected]",
pass: process.env.EMAIL_PASSWORD
}
var smtpTransport = nodemailer.createTransport('SMTP',{
service: 'Gmail',
auth: {
user: '[email protected]',
pass: process.env.EMAIL_PASSWORD
}
});
var twitter = new twit({
consumer_key: auth.twitterAuth.consumerKey,
Expand Down Expand Up @@ -86,9 +86,9 @@ module.exports = function(server, sessionStore) {
}
User.findById(session.passport.user, function(err, currentUser) {
if(err) {
console.log("user retrieval failed - error: " + err);
console.log('user retrieval failed - error: ' + err);
} else if(currentUser === null) {
console.log("current user null - session user: " + session.passport.user);
console.log('current user null - session user: ' + session.passport.user);
} else {
if(userToSocket[currentUser._id]) {
userToSocket[currentUser._id].push(socket);
Expand Down Expand Up @@ -135,7 +135,7 @@ module.exports = function(server, sessionStore) {
Gamestate.findById(gameID, function(err, gamestate) {
if(err) { console.log('load find err: ' + err); }
if(gamestate && gamestate.userIsInGame(currentUser)) {
gamestate.populate('placedTiles.tile activeTile.tile unusedTiles players.user',
gamestate.populate('placedTiles.tile activeTile.tile unusedTiles players.user',
'cities.meepleOffset farms.meepleOffset roads.meepleOffset cloister tower.offset imageURL username',
function(err, gamestate) {
if(err) { console.log('load populate err: ' + err); }
Expand All @@ -147,32 +147,32 @@ module.exports = function(server, sessionStore) {
});
socket.on('remove game', function(gameID) {
Gamestate.findByIdAndRemove(gameID, function(err, gamestate) {
if(err || !gamestate) {
if(err || !gamestate) {
console.log('remove game err: ' + err);
} else {
gamestate.populate('players.user', function(err, gamestate) {
for(var i = 0; i < gamestate.players.length; i++) {
User.findByIdAndUpdate(gamestate.players[i].user, { $pull: { activeGames: gamestate._id }}).exec();
}
}
});
}
});
});
socket.on('sending move', function(gameID, move, autocomplete) {
Gamestate.findById(gameID, function(err, gamestate) {
if(err || !gamestate) {
console.log('load find err: ' + err);
if(err || !gamestate) {
console.log('load find err: ' + err);
} else if(move && gamestate.userIsActive(currentUser)) {
gamestate.placeTile(move, function(err, gamestate) {
if(err || !gamestate) {
console.log('place tile err: ' + err);
console.log('place tile err: ' + err);
} else {
gamestate.markModified('unusedTiles');
gamestate.markModified('activeTile.tile');
gamestate.populate('placedTiles.tile activeTile.tile unusedTiles players.user',
'cities.meepleOffset farms.meepleOffset roads.meepleOffset cloister tower.offset imageURL email_notifications twitter_notifications username local.email facebook.email google.email twitter.username',
function(err, gamestate) {
if(err) {
if(err) {
console.log('send move populate err: ' + err);
} else {
var activeUser, previousUser;
Expand All @@ -189,10 +189,10 @@ module.exports = function(server, sessionStore) {
// send e-mail notification if we have a valid e-mail and the user has the option enabled
if(activeEmail && activeUser.email_notifications) {
smtpTransport.sendMail({
from: "Concarneau <[email protected]",
from: 'Concarneau <[email protected]',
to: activeEmail,
subject: "Your turn!",
text: "There is a Concarneau game where it is your turn: https://concarneau.herokuapp.com"
subject: 'Your turn!',
text: 'There is a Concarneau game where it is your turn: https://concarneau.herokuapp.com'
}, function(err, res) {
if(err) {
console.log('e-mail failed: ' + err);
Expand All @@ -201,7 +201,7 @@ module.exports = function(server, sessionStore) {
}
// send twitter notification if we have a valid twitter handle and the user has the option enabled
if(activeUser.twitter.username && activeUser.twitter_notifications) {
twitter.post('statuses/update', { status: '@' + activeUser.twitter.username + ' There is a Concarneau game where it is your turn: https://concarneau.herokuapp.com?' + Math.floor(Math.random()*1000000) }, function(err, data, response) {
twitter.post('statuses/update', { status: '@' + activeUser.twitter.username + ' There is a Concarneau game where it is your turn: https://concarneau.herokuapp.com?' + Math.floor(Math.random()*1000000) }, function(err) {
if(err) {
console.log('twitter failed: ' + err);
}
Expand Down Expand Up @@ -245,7 +245,6 @@ module.exports = function(server, sessionStore) {
socket.emit('friend not found');
}
});

});
socket.on('remove friend', function(userID) {
User.findByIdAndUpdate(currentUser._id, { $pull: { friends: userID }}).exec();
Expand Down Expand Up @@ -294,4 +293,4 @@ module.exports = function(server, sessionStore) {
});
});
});
};
};
Loading

0 comments on commit 9a43cb9

Please sign in to comment.