2020-08-27 11:28:15 -04:00
|
|
|
const { waitForDb } = require('../../../../app/js/mongodb')
|
2018-12-20 14:14:11 -05:00
|
|
|
const app = require('../../../../app')
|
2018-01-29 07:01:26 -05:00
|
|
|
|
2022-01-10 04:29:32 -05:00
|
|
|
let serverPromise = null
|
|
|
|
function startServer(resolve, reject) {
|
|
|
|
waitForDb()
|
|
|
|
.then(() => {
|
2022-01-07 05:41:23 -05:00
|
|
|
app.listen(3010, 'localhost', error => {
|
2022-01-07 05:29:50 -05:00
|
|
|
if (error) {
|
2022-01-10 04:29:32 -05:00
|
|
|
return reject(error)
|
2022-01-07 05:41:57 -05:00
|
|
|
}
|
2022-01-10 04:29:32 -05:00
|
|
|
resolve()
|
2018-12-20 14:14:11 -05:00
|
|
|
})
|
2020-08-27 11:28:15 -04:00
|
|
|
})
|
2022-01-10 04:29:32 -05:00
|
|
|
.catch(reject)
|
|
|
|
}
|
|
|
|
|
|
|
|
async function ensureRunning() {
|
|
|
|
if (!serverPromise) {
|
|
|
|
serverPromise = new Promise(startServer)
|
|
|
|
}
|
|
|
|
return serverPromise
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
ensureRunning,
|
2018-12-20 14:14:11 -05:00
|
|
|
}
|