mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-30 10:56:53 -05:00
Changed read prefs and enabled middleware
This commit is contained in:
parent
c25d36ee76
commit
a16ae2b5bc
17 changed files with 36 additions and 19 deletions
|
@ -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(
|
||||
{
|
||||
|
|
|
@ -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(
|
||||
{
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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(
|
||||
{
|
||||
|
|
|
@ -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(
|
||||
{
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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})
|
||||
|
|
|
@ -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(
|
||||
{
|
||||
|
|
|
@ -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(
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ setupTrailingSlashRemovingMiddleware = (app) ->
|
|||
next()
|
||||
|
||||
exports.setupMiddleware = (app) ->
|
||||
#setupChinaRedirectMiddleware app
|
||||
setupChinaRedirectMiddleware app
|
||||
setupMiddlewareToSendOldBrowserWarningWhenPlayersViewLevelDirectly app
|
||||
setupExpressMiddleware app
|
||||
setupPassportMiddleware app
|
||||
|
|
Loading…
Reference in a new issue