2021-04-22 10:07:10 +02:00
|
|
|
import { IUnleashStores } from '../types/stores';
|
|
|
|
import { IUnleashConfig } from '../types/option';
|
|
|
|
import { Logger } from '../logger';
|
2021-08-12 15:04:37 +02:00
|
|
|
import { IFeatureTypeStore } from '../types/stores/feature-type-store';
|
2021-04-22 10:07:10 +02:00
|
|
|
|
|
|
|
class HealthService {
|
2021-08-12 15:04:37 +02:00
|
|
|
private featureTypeStore: IFeatureTypeStore;
|
2021-04-22 10:07:10 +02:00
|
|
|
|
|
|
|
private logger: Logger;
|
|
|
|
|
|
|
|
constructor(
|
2021-08-12 15:04:37 +02:00
|
|
|
{ featureTypeStore }: Pick<IUnleashStores, 'featureTypeStore'>,
|
2021-04-22 10:07:10 +02:00
|
|
|
{ getLogger }: Pick<IUnleashConfig, 'getLogger'>,
|
|
|
|
) {
|
2021-08-12 15:04:37 +02:00
|
|
|
this.featureTypeStore = featureTypeStore;
|
2021-04-22 10:07:10 +02:00
|
|
|
this.logger = getLogger('services/health-service.ts');
|
|
|
|
}
|
|
|
|
|
|
|
|
async dbIsUp(): Promise<boolean> {
|
2021-08-12 15:04:37 +02:00
|
|
|
const row = await this.featureTypeStore.getAll();
|
|
|
|
return row.length > 0;
|
2021-04-22 10:07:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default HealthService;
|
|
|
|
module.exports = HealthService;
|