|
|
@@ -7,20 +7,26 @@
|
|
|
|
|
|
require('module-alias/register');
|
|
|
|
|
|
+const { URL } = require('url');
|
|
|
+
|
|
|
const { getMongoUri } = require('@commons/util/mongoose-utils');
|
|
|
|
|
|
const mongoUri = getMongoUri();
|
|
|
-const match = mongoUri.match(/^(.+)\/([^/]+)$/);
|
|
|
+
|
|
|
+// parse url
|
|
|
+const url = new URL(mongoUri);
|
|
|
+
|
|
|
+const mongodb = {
|
|
|
+ url: `${url.protocol}//${url.host}`,
|
|
|
+ databaseName: url.pathname.substring(1), // omit heading slash
|
|
|
+ options: {
|
|
|
+ useNewUrlParser: true, // removes a deprecation warning when connecting
|
|
|
+ },
|
|
|
+};
|
|
|
|
|
|
module.exports = {
|
|
|
mongoUri,
|
|
|
- mongodb: {
|
|
|
- url: match[0],
|
|
|
- databaseName: match[2],
|
|
|
- options: {
|
|
|
- useNewUrlParser: true, // removes a deprecation warning when connecting
|
|
|
- },
|
|
|
- },
|
|
|
+ mongodb,
|
|
|
migrationsDir: 'src/migrations/',
|
|
|
changelogCollectionName: 'migrations',
|
|
|
};
|