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 1 commit
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

[email protected]
[email protected]
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:[email protected]
rocketchat:[email protected]
rocketchat:[email protected]
rocketchat:[email protected]
rocketchat:[email protected]
rocketchat:[email protected]_3
rocketchat:[email protected]
rocketchat:[email protected]
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');
});
21 changes: 21 additions & 0 deletions packages/rocketchat-mongo-config/server/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Mongo } from 'meteor/mongo';

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';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still need this? seems node have fixed it already.

this is not related to mongo btw, so I don't it should be in this package =) but my vote is to remove.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


// 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);