fix: modified uri parsing for mongodb (#2282)

This commit is contained in:
Wyatt Johnson
2019-04-25 15:16:36 +00:00
committed by GitHub
parent 205e6fcd08
commit a91de05af9
4 changed files with 48 additions and 9 deletions
+8 -6
View File
@@ -1,19 +1,21 @@
import convict from "convict";
import Joi from "joi";
import { parseConnectionString } from "mongodb-core";
import os from "os";
import { LOCALES } from "talk-common/helpers/i18n/locales";
import { InternalError } from "./errors";
// Add custom format for the mongo uri scheme.
convict.addFormat({
name: "mongo-uri",
validate: (url: string) => {
Joi.assert(
url,
Joi.string().uri({
scheme: ["mongodb"],
})
);
parseConnectionString(url, err => {
if (err) {
throw new InternalError(err, "invalid mongo-uri");
}
});
},
});