refactor(database): waitForConnection

This commit is contained in:
Linden committed 2022-11-08 17:29:05 +11:00
1 parent 2a5e110e29
commit bc8a874743
5 files changed
+30 -22

No files matched your search

+13
View File
@@ -5,6 +5,19 @@ import { typeCast } from '../utils/typeCast';
let pool: Pool;
let serverReady = false;
export async function waitForConnection() {
if (!serverReady) {
await new Promise<void>((resolve) => {
(function wait() {
if (serverReady) {
return resolve();
}
setTimeout(wait);
})();
});
}
}
setTimeout(() => {
pool = createPool({
connectTimeout: 60000,