/
githubmirror
/
nest
Обзор
Документация
Войти
/
githubmirror
/
nest
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
integration/repl/src/database/database.connection.ts
24 строки
520 B
Dmitry Zhlobo
fix(core): gracefully shutdown the app when repl exits
28 май 2025, 15:59
28 май 2025, 15:59
b84c1fe
Код
Авторство
О чём код?
import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common'; @Injectable() export class DatabaseConnection implements OnModuleDestroy { keepAlive = true; static connect(): DatabaseConnection { const connection = new DatabaseConnection(); connection.maintainConnection(); return connection; } onModuleDestroy() { this.keepAlive = false; } maintainConnection() { setTimeout(() => { if (this.keepAlive) { this.maintainConnection(); } }, 10); } }