Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move mongo config away from cors package #13531

Merged
merged 2 commits into from
Feb 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);