Skip to content

Commit

Permalink
Move mongo config away from cors package (#13531)
Browse files Browse the repository at this point in the history
* Move mongo config away from cors package

* Remove TLS fix
  • Loading branch information
rodrigok committed Feb 22, 2019
1 parent 00c59f2 commit cdfc3c0
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 20 deletions.
1 change: 1 addition & 0 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# but you can also edit it by hand.

rocketchat:cors
rocketchat:mongo-config

accounts-facebook@1.3.2
accounts-github@1.4.2
Expand Down
1 change: 1 addition & 0 deletions .meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ rocketchat:message-star@0.0.1
rocketchat:metrics@0.0.1
rocketchat:migrations@0.0.1
rocketchat:models@1.0.0
rocketchat:mongo-config@0.0.1
rocketchat:monitoring@2.30.2_3
rocketchat:notifications@0.0.1
rocketchat:nrr@1.0.0
Expand Down
20 changes: 0 additions & 20 deletions packages/rocketchat-cors/server/cors.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,11 @@
import { Meteor } from 'meteor/meteor';
import { WebApp, WebAppInternals } from 'meteor/webapp';
import { settings } from 'meteor/rocketchat:settings';
import { Mongo } from 'meteor/mongo';
import { Logger } from 'meteor/rocketchat:logger';
const logger = new Logger('CORS', {});

import _ from 'underscore';
import url from 'url';
import tls from 'tls';
// FIX For TLS error see more here https://github.com/RocketChat/Rocket.Chat/issues/9316
// TODO: Remove after NodeJS fix it, more information https://github.com/nodejs/node/issues/16196 https://github.com/nodejs/node/pull/16853
tls.DEFAULT_ECDH_CURVE = 'auto';

// Revert change from Meteor 1.6.1 who set ignoreUndefined: true
// more information https://github.com/meteor/meteor/pull/9444
let mongoOptions = {
ignoreUndefined: false,
};

const mongoOptionStr = process.env.MONGO_OPTIONS;
if (typeof mongoOptionStr !== 'undefined') {
const jsonMongoOptions = JSON.parse(mongoOptionStr);

mongoOptions = Object.assign({}, mongoOptions, jsonMongoOptions);
}

Mongo.setConnectionOptions(mongoOptions);

WebApp.rawConnectHandlers.use(Meteor.bindEnvironment(function(req, res, next) {
if (req._body) {
Expand Down
15 changes: 15 additions & 0 deletions packages/rocketchat-mongo-config/package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Package.describe({
name: 'rocketchat:mongo-config',
version: '0.0.1',
summary: '',
git: '',
});

Package.onUse(function(api) {
api.use([
'ecmascript',
'mongo',
]);

api.mainModule('server/index.js', 'server');
});
16 changes: 16 additions & 0 deletions packages/rocketchat-mongo-config/server/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Mongo } from 'meteor/mongo';

// Revert change from Meteor 1.6.1 who set ignoreUndefined: true
// more information https://github.com/meteor/meteor/pull/9444
let mongoOptions = {
ignoreUndefined: false,
};

const mongoOptionStr = process.env.MONGO_OPTIONS;
if (typeof mongoOptionStr !== 'undefined') {
const jsonMongoOptions = JSON.parse(mongoOptionStr);

mongoOptions = Object.assign({}, mongoOptions, jsonMongoOptions);
}

Mongo.setConnectionOptions(mongoOptions);

0 comments on commit cdfc3c0

Please sign in to comment.