Changed read prefs and enabled middleware

This commit is contained in:
Michael Schmatz 2015-03-21 21:49:32 -04:00
parent c25d36ee76
commit a16ae2b5bc
17 changed files with 36 additions and 19 deletions

View file

@ -5,6 +5,7 @@ utils = require '../../app/core/utils'
plugins = require('../plugins/plugins')
AchievablePlugin = require '../plugins/achievements'
TreemaUtils = require '../../bower_components/treema/treema-utils.js'
config = require '../../server_config'
# `pre` and `post` are not called for update operations executed directly on the database,
# including `Model.update`,`.findByIdAndUpdate`,`.findOneAndUpdate`, `.findOneAndRemove`,and `.findByIdAndRemove`.order
@ -13,7 +14,7 @@ TreemaUtils = require '../../bower_components/treema/treema-utils.js'
AchievementSchema = new mongoose.Schema({
userField: String
}, {strict: false,read:'nearest'})
}, {strict: false,read: config.mongo.readpref})
AchievementSchema.index(
{

View file

@ -1,7 +1,8 @@
mongoose = require 'mongoose'
plugins = require '../plugins/plugins'
config = require '../../server_config'
ArticleSchema = new mongoose.Schema(body: String, {strict: false,read:'nearest'})
ArticleSchema = new mongoose.Schema(body: String, {strict: false,read:config.mongo.readpref})
ArticleSchema.index(
{

View file

@ -1,8 +1,9 @@
mongoose = require 'mongoose'
plugins = require '../plugins/plugins'
log = require 'winston'
config = require '../../server_config'
CampaignSchema = new mongoose.Schema(body: String, {strict: false,read:'nearest'})
CampaignSchema = new mongoose.Schema(body: String, {strict: false,read:config.mongo.readpref})
CampaignSchema.index({i18nCoverage: 1}, {name: 'translation coverage index', sparse: true})
CampaignSchema.index({slug: 1}, {name: 'slug index', sparse: true, unique: true})

View file

@ -1,10 +1,11 @@
mongoose = require 'mongoose'
plugins = require '../plugins/plugins'
jsonschema = require '../../app/schemas/models/level'
config = require '../../server_config'
LevelSchema = new mongoose.Schema({
description: String
}, {strict: false, read:'nearest'})
}, {strict: false, read:config.mongo.readpref})
LevelSchema.index(
{

View file

@ -1,11 +1,12 @@
mongoose = require 'mongoose'
plugins = require '../../plugins/plugins'
jsonschema = require '../../../app/schemas/models/level_component'
config = require '../../../server_config'
LevelComponentSchema = new mongoose.Schema {
description: String
system: String
}, {strict: false, read:'nearest'}
}, {strict: false, read:config.mongo.readpref}
LevelComponentSchema.index(
{

View file

@ -3,12 +3,13 @@
mongoose = require 'mongoose'
plugins = require '../../plugins/plugins'
jsonschema = require '../../../app/schemas/models/level_feedback'
config = require '../../../server_config'
LevelFeedbackSchema = new mongoose.Schema({
created:
type: Date
'default': Date.now
}, {strict: false,read:'nearest'})
}, {strict: false,read:config.mongo.readpref})
LevelFeedbackSchema.index({created: 1})
LevelFeedbackSchema.index({creator: 1})

View file

@ -3,12 +3,13 @@ plugins = require '../../plugins/plugins'
AchievablePlugin = require '../../plugins/achievements'
jsonschema = require '../../../app/schemas/models/level_session'
log = require 'winston'
config = require '../../../server_config'
LevelSessionSchema = new mongoose.Schema({
created:
type: Date
'default': Date.now
}, {strict: false,read:'nearest'})
}, {strict: false,read:config.mongo.readpref})
LevelSessionSchema.index({creator: 1})
LevelSessionSchema.index({level: 1})

View file

@ -1,10 +1,11 @@
mongoose = require 'mongoose'
plugins = require '../../plugins/plugins'
jsonschema = require '../../../app/schemas/models/level_system'
config = require '../../../server_config'
LevelSystemSchema = new mongoose.Schema {
description: String
}, {strict: false,read:'nearest'}
}, {strict: false,read:config.mongo.readpref}
LevelSystemSchema.index(
{

View file

@ -1,9 +1,10 @@
mongoose = require 'mongoose'
plugins = require '../../plugins/plugins'
config = require '../../../server_config'
ThangTypeSchema = new mongoose.Schema({
body: String,
}, {strict: false,read:'nearest'})
}, {strict: false,read:config.mongo.readpref})
ThangTypeSchema.index(
{

View file

@ -2,8 +2,9 @@ mongoose = require('mongoose')
deltas = require '../../app/core/deltas'
log = require 'winston'
{handlers} = require '../commons/mapping'
config = require '../../server_config'
PatchSchema = new mongoose.Schema({status: String}, {strict: false,read:'nearest'})
PatchSchema = new mongoose.Schema({status: String}, {strict: false,read:config.mongo.readpref})
PatchSchema.pre 'save', (next) ->
return next() unless @isNew # patch can't be altered after creation, so only need to check data once

View file

@ -1,6 +1,7 @@
mongoose = require('mongoose')
config = require '../../server_config'
PaymentSchema = new mongoose.Schema({}, {strict: false, read:'nearest'})
PaymentSchema = new mongoose.Schema({}, {strict: false, read:config.mongo.readpref})
PaymentSchema.index({recipient: 1, 'stripe.timestamp': 1, 'ios.transactionID'}, {unique: true, name: 'unique payment'})
module.exports = mongoose.model('payment', PaymentSchema)

View file

@ -2,12 +2,12 @@ mongoose = require 'mongoose'
plugins = require '../plugins/plugins'
jsonSchema = require '../../app/schemas/models/poll.schema'
log = require 'winston'
config = require '../../server_config'
PollSchema = new mongoose.Schema {
created:
type: Date
'default': Date.now
}, {strict: false, minimize: false,read:'nearest'}
}, {strict: false, minimize: false,read:config.mongo.readpref}
PollSchema.index {priority: 1}

View file

@ -1,5 +1,5 @@
mongoose = require 'mongoose'
PrepaidSchema = new mongoose.Schema {}, {strict: false, minimize: false,read:'nearest'}
config = require '../../server_config'
PrepaidSchema = new mongoose.Schema {}, {strict: false, minimize: false,read:config.mongo.readpref}
module.exports = Prepaid = mongoose.model('prepaid', PrepaidSchema)

View file

@ -1,6 +1,6 @@
mongoose = require('mongoose')
PurchaseSchema = new mongoose.Schema({status: String}, {strict: false,read:'nearest'})
config = require '../../server_config'
PurchaseSchema = new mongoose.Schema({status: String}, {strict: false,read:config.mongo.readpref})
PurchaseSchema.index({recipient: 1, 'purchased.original': 1}, {unique: true, name: 'unique purchase'})
module.exports = mongoose.model('purchase', PurchaseSchema)

View file

@ -1,10 +1,11 @@
mongoose = require 'mongoose'
plugins = require '../plugins/plugins'
config = require '../../server_config'
UserCodeProblemSchema = new mongoose.Schema({
created:
type: Date
'default': Date.now
}, {strict: false,read:'nearest'})
}, {strict: false,read:config.mongo.readpref})
module.exports = UserCodeProblem = mongoose.model('user.code.problem', UserCodeProblemSchema)

View file

@ -20,6 +20,11 @@ config.mongo =
mongoose_replica_string: process.env.COCO_MONGO_MONGOOSE_REPLICA_STRING or ''
mongoose_tokyo_replica_string: process.env.COCO_MONGO_MONGOOSE_TOKYO_REPLICA_STRING or ''
if config.tokyo
config.mongo.readpref = 'nearest'
else
config.mongo.readpref = 'primary'
config.apple =
verifyURL: process.env.COCO_APPLE_VERIFY_URL or 'https://sandbox.itunes.apple.com/verifyReceipt'

View file

@ -131,7 +131,7 @@ setupTrailingSlashRemovingMiddleware = (app) ->
next()
exports.setupMiddleware = (app) ->
#setupChinaRedirectMiddleware app
setupChinaRedirectMiddleware app
setupMiddlewareToSendOldBrowserWarningWhenPlayersViewLevelDirectly app
setupExpressMiddleware app
setupPassportMiddleware app