-
Notifications
You must be signed in to change notification settings - Fork 5
/
migrate-mongo-config.js
38 lines (27 loc) · 1.11 KB
/
migrate-mongo-config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
if (process.env.NODE_ENV !== 'production') {
require('dotenv').config()
}
const { MONGODB_URI } = process.env
const regex = new RegExp(`\/([A-Z0-9a-z\_])*$`, 'g') // eslint-disable-line
const mongodbURI = MONGODB_URI
const mongoUrl = mongodbURI.replace(regex, '')
const mongoDBName = mongodbURI.replace(mongoUrl, '').replace('/', '')
console.log('mongodbURI', mongodbURI)
const config = {
mongodb: {
url: mongodbURI,
databaseName: mongoDBName,
options: {
useNewUrlParser: true, // removes a deprecation warning when connecting
useUnifiedTopology: true // removes a deprecating warning when connecting
// connectTimeoutMS: 3600000, // increase connection timeout to 1 hour
// socketTimeoutMS: 3600000, // increase socket timeout to 1 hour
}
},
// The migrations dir, can be an relative or absolute path. Only edit this when really necessary.
migrationsDir: 'migrations',
// The mongodb collection where the applied changes are stored. Only edit this when really necessary.
changelogCollectionName: 'changelog'
}
// Return the config as a promise
module.exports = config