Skip to content

Commit

Permalink
Merge pull request btouellette#35 from btouellette/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
btouellette committed Aug 3, 2020
2 parents 92b5e42 + 487c290 commit 92a24a2
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 27 deletions.
10 changes: 5 additions & 5 deletions app/gameserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var cookieParser = require('cookie-parser');
var nodemailer = require('nodemailer');
var smtp = require('nodemailer-smtp-transport');
var xoauth2 = require('xoauth2');
var twit = require('twit');
var twit = require('twit'); // TODO: this is not supported any longer, replace with https://github.com/draftbit/twitter-lite
var auth = require('../config/auth');

// load up the gamestate model
Expand Down Expand Up @@ -40,22 +40,22 @@ var twitter = new twit({

module.exports = function(server, sessionStore) {
// if the tile db is empty load in the tiles,
Tile.count({ expansion: 'base-game' }, function(err, count) {
Tile.countDocuments({ expansion: 'base-game' }, function(err, count) {
if(!err && count === 0) {
Tile.loadTilesBase();
}
});
Tile.count({ expansion: 'inns-and-cathedrals' }, function(err, count) {
Tile.countDocuments({ expansion: 'inns-and-cathedrals' }, function(err, count) {
if(!err && count === 0) {
Tile.loadTilesIAC();
}
});
Tile.count({ expansion: 'traders-and-builders' }, function(err, count) {
Tile.countDocuments({ expansion: 'traders-and-builders' }, function(err, count) {
if(!err && count === 0) {
Tile.loadTilesTAB();
}
});
Tile.count({ expansion: 'the-tower' }, function(err, count) {
Tile.countDocuments({ expansion: 'the-tower' }, function(err, count) {
if(!err && count === 0) {
Tile.loadTilesTT();
}
Expand Down
4 changes: 2 additions & 2 deletions app/models/gamestate.js
Original file line number Diff line number Diff line change
Expand Up @@ -1502,7 +1502,7 @@ function checkAndFinalizeFeature(placedTile, featureIndex, featureType, gameFini
if(scoringPlayers.length > 0 && scoredPoints > 0) {
message = scoringPlayers.map(function(player) {
return player.user.username + ' (' + player.points + ')';
}).join(' and ') + ' scored ' + scoredPoints + ' for ' + (featureType === 'farm' ? ' a ' : gameFinished ? 'an uncomplete ' : 'a completed ') + featureType;
}).join(' and ') + ' scored ' + scoredPoints + ' for ' + (featureType === 'farm' ? 'a ' : gameFinished ? 'an uncomplete ' : 'a completed ') + featureType;
if(featureInfo.cathedral) {
message += ' with a cathedral';
} else if(featureInfo.inn) {
Expand Down Expand Up @@ -1588,4 +1588,4 @@ function getFeatureIndex(placedTile, type, direction) {
}

// create the model for game information and expose it to our app
module.exports = mongoose.model('Gamestate', gamestateSchema);
module.exports = mongoose.model('Gamestate', gamestateSchema);
9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,23 @@
"name": "concarneau",
"main": "server.js",
"dependencies": {
"@risingstack/trace": "^2.36.0",
"bcrypt-nodejs": "latest",
"body-parser": "^1.17.2",
"compression": "^1.7.0",
"connect-flash": "^0.1.1",
"connect-mongo": "^1.3.2",
"connect-mongo": "^3.2.0",
"cookie": "^0.3.1",
"cookie-parser": "^1.4.3",
"ejs": "^2.5.7",
"express": "^4.15.4",
"express-session": "^1.15.5",
"flatted": "^2.0.2",
"helmet": "^3.8.1",
"mongoose": "^4.11.6",
"mongoose": "^5.9.24",
"moniker": "^0.1.2",
"newrelic": "^2.0.2",
"newrelic": "^6.11.0",
"nodemailer": "^2.7.2",
"nodemailer-smtp-transport": "^2.7.4",
"nodetime": "^0.8.17",
"passport": "^0.3.2",
"passport-facebook": "^2.1.1",
"passport-google-oauth": "^1.0.0",
Expand All @@ -29,7 +27,6 @@
"q": "^2.0.3",
"raven": "^0.12.3",
"socket.io": "^2.0.3",
"spm-agent-nodejs": "^1.30.9",
"tunnel": "^0.0.4",
"twit": "^2.2.9",
"xoauth2": "^1.2.0",
Expand Down
19 changes: 5 additions & 14 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,10 @@ if(process.env.C9_PROJECT/* && !process.env.MONGOLAB_URI*/) {
require('./config/c9');
}

// if configured to use trace, nodetime, spm, or newrelic connect to it
if(process.env.TRACE_SERVICE_NAME) {
require('@risingstack/trace');
}
// if configured to use newrelic connect to it
if(process.env.NEW_RELIC_LICENSE_KEY) {
require('newrelic');
}
if(process.env.SPM_TOKEN) {
require ('spm-agent-nodejs');
}
if(process.env.NODETIME_ACCOUNT_KEY) {
require('nodetime').profile({
accountKey: process.env.NODETIME_ACCOUNT_KEY,
appName: 'Concarneau'
});
}

var port = process.env.PORT || 8080;

Expand Down Expand Up @@ -70,8 +58,11 @@ var sessionStore = new MongoStore({
autoReconnect: true
});

mongoose.set('useCreateIndex', true); // handle deprecations: https://mongoosejs.com/docs/deprecations.html
mongoose.set('useNewUrlParser', true);
mongoose.set('useUnifiedTopology', true);
mongoose.plugin(schema => { schema.options.usePushEach = true }); // MongoDB 3.6+ deprecates $pushAll, set flag for mongoose to avoid that operator
mongoose.connect(configDB.url, { useMongoClient: true }); // connect to our database
mongoose.connect(configDB.url); // connect to our database

require('./config/passport')(passport); // pass passport for configuration

Expand Down

0 comments on commit 92a24a2

Please sign in to comment.