Skip to content

Commit

Permalink
chore: add eslint rule for import sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunnerLivio committed Sep 14, 2023
1 parent f805f54 commit 29bb4bd
Show file tree
Hide file tree
Showing 24 changed files with 238 additions and 121 deletions.
2 changes: 1 addition & 1 deletion lib/errors/connection-not-found.error.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HealthCheckError } from '../health-check/health-check.error';
import { CONNECTION_NOT_FOUND } from './messages.constant';
import { HealthCheckError } from '../health-check/health-check.error';

/**
* Error which gets thrown when the connection
Expand Down
2 changes: 1 addition & 1 deletion lib/errors/storage-exceeded.error.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HealthCheckError } from '../health-check/health-check.error';
import { STORAGE_EXCEEDED } from './messages.constant';
import { HealthCheckError } from '../health-check/health-check.error';

/**
* Error which gets thrown when the given storage threshold
Expand Down
2 changes: 1 addition & 1 deletion lib/errors/timeout-error.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HealthCheckError } from '../health-check/health-check.error';
import { TIMEOUT_EXCEEDED } from './messages.constant';
import { HealthCheckError } from '../health-check/health-check.error';

/**
* Gets thrown when the timeout of the health check exceeds
Expand Down
2 changes: 1 addition & 1 deletion lib/errors/unhealthy-response-code.error.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HealthCheckError } from '../health-check/health-check.error';
import { UNHEALTHY_RESPONSE_CODE } from './messages.constant';
import { HealthCheckError } from '../health-check/health-check.error';

/**
* Error which gets thrown when the terminus client receives
Expand Down
2 changes: 1 addition & 1 deletion lib/health-check/error-logger/error-logger.provider.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Provider } from '@nestjs/common';
import { ErrorLogStyle } from '../../terminus-options.interface';
import { ErrorLogger } from './error-logger.interface';
import { JsonErrorLogger } from './json-error-logger.service';
import { PrettyErrorLogger } from './pretty-error-logger.service';
import { ErrorLogStyle } from '../../terminus-options.interface';

export const ERROR_LOGGER = 'TERMINUS_ERROR_LOGGER';

Expand Down
4 changes: 2 additions & 2 deletions lib/health-check/error-logger/pretty-error-logger.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { HealthIndicatorResult } from '../../health-indicator';
import { ErrorLogger } from './error-logger.interface';
import * as boxen from 'boxen';
import { ErrorLogger } from './error-logger.interface';
import { HealthIndicatorResult } from '../../health-indicator';

const GREEN = '\x1b[0m\x1b[32m';
const RED = '\x1b[0m\x1b[31m';
Expand Down
10 changes: 5 additions & 5 deletions lib/health-check/health-check-executor.service.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Injectable, BeforeApplicationShutdown } from '@nestjs/common';
import {
HealthIndicatorFunction,
HealthIndicatorResult,
} from '../health-indicator';
import { HealthCheckError } from '../health-check/health-check.error';
import {
HealthCheckResult,
HealthCheckStatus,
} from './health-check-result.interface';
import { HealthCheckError } from '../health-check/health-check.error';
import {
HealthIndicatorFunction,
HealthIndicatorResult,
} from '../health-indicator';
import { isHealthCheckError } from '../utils';

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/health-check/health-check.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import {
ConsoleLogger,
LoggerService,
} from '@nestjs/common';
import { HealthIndicatorFunction } from '../health-indicator';
import { ErrorLogger } from './error-logger/error-logger.interface';
import { ERROR_LOGGER } from './error-logger/error-logger.provider';
import { HealthCheckExecutor } from './health-check-executor.service';
import { HealthCheckResult } from './health-check-result.interface';
import { TERMINUS_LOGGER } from './logger/logger.provider';
import { HealthIndicatorFunction } from '../health-indicator';

/**
* Handles Health Checks which can be used in
Expand Down
7 changes: 3 additions & 4 deletions lib/health-indicator/database/mikro-orm.health.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import * as MikroOrm from '@mikro-orm/core';
import { Injectable, Scope } from '@nestjs/common';
import { ModuleRef } from '@nestjs/core';
import { HealthCheckError } from '../../health-check';

import * as MikroOrm from '@mikro-orm/core';
import { HealthIndicator, HealthIndicatorResult } from '..';
import { TimeoutError } from '../../errors';
import { HealthCheckError } from '../../health-check';
import {
TimeoutError as PromiseTimeoutError,
promiseTimeout,
checkPackages,
} from '../../utils';
import { HealthIndicator, HealthIndicatorResult } from '..';

export interface MikroOrmPingCheckSettings {
/**
Expand Down
14 changes: 6 additions & 8 deletions lib/health-indicator/database/mongoose.health.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import { Injectable, Scope } from '@nestjs/common';
import { ModuleRef } from '@nestjs/core';
import { HealthCheckError } from '../../health-check/health-check.error';

import * as NestJSMongoose from '@nestjs/mongoose';

import {
promiseTimeout,
TimeoutError as PromiseTimeoutError,
checkPackages,
} from '../../utils';
import {
HealthIndicatorResult,
TimeoutError,
ConnectionNotFoundError,
} from '../..';
import { HealthCheckError } from '../../health-check/health-check.error';
import {
promiseTimeout,
TimeoutError as PromiseTimeoutError,
checkPackages,
} from '../../utils';
import { HealthIndicator } from '../health-indicator';

export interface MongoosePingCheckSettings {
Expand Down
6 changes: 3 additions & 3 deletions lib/health-indicator/database/prisma.health.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Injectable } from '@nestjs/common';
import { TimeoutError } from '../../errors';
import { HealthCheckError } from '../../health-check';
import {
promiseTimeout,
TimeoutError as PromiseTimeoutError,
} from '../../utils';
import { HealthIndicator } from '../health-indicator';
import { TimeoutError } from '../../errors';
import { HealthCheckError } from '../../health-check';
import { Injectable } from '@nestjs/common';

type PingCommandSignature = { [Key in string]?: number };

Expand Down
13 changes: 6 additions & 7 deletions lib/health-indicator/database/sequelize.health.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { Injectable, Scope } from '@nestjs/common';
import { ModuleRef } from '@nestjs/core';
import { HealthCheckError } from '../../health-check/health-check.error';
import * as NestJSSequelize from '@nestjs/sequelize';

import {
promiseTimeout,
TimeoutError as PromiseTimeoutError,
checkPackages,
} from '../../utils';
import {
HealthIndicatorResult,
TimeoutError,
ConnectionNotFoundError,
} from '../..';
import { HealthCheckError } from '../../health-check/health-check.error';
import {
promiseTimeout,
TimeoutError as PromiseTimeoutError,
checkPackages,
} from '../../utils';
import { HealthIndicator } from '../health-indicator';

export interface SequelizePingCheckSettings {
Expand Down
8 changes: 3 additions & 5 deletions lib/health-indicator/database/typeorm.health.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import { Injectable, Scope } from '@nestjs/common';
import { ModuleRef } from '@nestjs/core';
import { HealthCheckError } from '../../health-check/health-check.error';

import * as TypeOrm from 'typeorm';
import * as NestJSTypeOrm from '@nestjs/typeorm';

import * as TypeOrm from 'typeorm';
import { HealthIndicator, HealthIndicatorResult } from '../';
import {
TimeoutError,
ConnectionNotFoundError,
MongoConnectionError,
} from '../../errors';
import { HealthCheckError } from '../../health-check/health-check.error';
import {
TimeoutError as PromiseTimeoutError,
promiseTimeout,
checkPackages,
} from '../../utils';
import { HealthIndicator, HealthIndicatorResult } from '../';

export interface TypeOrmPingCheckSettings {
/**
Expand Down
2 changes: 1 addition & 1 deletion lib/health-indicator/disk/disk-usage-lib.provider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import checkDiskSpace from 'check-disk-space';
import { CHECK_DISK_SPACE_LIB } from '../../terminus.constants';

import checkDiskSpace from 'check-disk-space';

/**
* Wrapper of the check-disk-space library.
Expand Down
9 changes: 4 additions & 5 deletions lib/health-indicator/disk/disk.health.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { Injectable, Inject } from '@nestjs/common';
import { isNil } from '@nestjs/common/utils/shared.utils';
import checkDiskSpace from 'check-disk-space';

import { HealthIndicator, HealthIndicatorResult } from '../';
import { CHECK_DISK_SPACE_LIB } from '../../terminus.constants';
import { StorageExceededError } from '../../errors';
import { STORAGE_EXCEEDED } from '../../errors/messages.constant';
import {
DiskHealthIndicatorOptions,
DiskOptionsWithThresholdPercent,
} from './disk-health-options.type';
import { HealthIndicator, HealthIndicatorResult } from '../';
import { StorageExceededError } from '../../errors';
import { STORAGE_EXCEEDED } from '../../errors/messages.constant';
import { CHECK_DISK_SPACE_LIB } from '../../terminus.constants';

type CheckDiskSpace = typeof checkDiskSpace;

Expand Down
1 change: 0 additions & 1 deletion lib/health-indicator/health-indicators.provider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Type } from '@nestjs/common';

import {
TypeOrmHealthIndicator,
HttpHealthIndicator,
Expand Down
12 changes: 6 additions & 6 deletions lib/health-indicator/http/http.health.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { URL } from 'url';
import type * as NestJSAxios from '@nestjs/axios';
import { ConsoleLogger, Inject, Injectable, Scope } from '@nestjs/common';
import { HealthIndicator, HealthIndicatorResult } from '..';
import { HealthCheckError } from '../../health-check/health-check.error';
import { lastValueFrom, Observable } from 'rxjs';
import { ModuleRef } from '@nestjs/core';
import { checkPackages, isAxiosError } from '../../utils';
import type * as NestJSAxios from '@nestjs/axios';
import { lastValueFrom, Observable } from 'rxjs';
import { AxiosRequestConfig, AxiosResponse } from './axios.interfaces';
import { URL } from 'url';
import { HealthIndicator, HealthIndicatorResult } from '..';
import { AxiosError } from '../../errors/axios.error';
import { HealthCheckError } from '../../health-check/health-check.error';
import { TERMINUS_LOGGER } from '../../health-check/logger/logger.provider';
import { checkPackages, isAxiosError } from '../../utils';

interface HttpClientLike {
request<T = any>(config: any): Observable<AxiosResponse<T>>;
Expand Down
2 changes: 1 addition & 1 deletion lib/health-indicator/memory/memory.health.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { HealthIndicator, HealthIndicatorResult } from '../';
import { STORAGE_EXCEEDED } from '../../errors/messages.constant';
import { StorageExceededError } from '../../errors';
import { STORAGE_EXCEEDED } from '../../errors/messages.constant';

/**
* The MemoryHealthIndicator contains checks which are related
Expand Down
4 changes: 2 additions & 2 deletions lib/health-indicator/microservice/grpc.health.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { HealthCheckError } from '../../health-check/health-check.error';
import { join } from 'path';
import { Injectable, Scope } from '@nestjs/common';
import type * as NestJSMicroservices from '@nestjs/microservices';
import { join } from 'path';
import { Observable, lastValueFrom } from 'rxjs';
import {
HealthIndicatorResult,
TimeoutError,
UnhealthyResponseCodeError,
} from '../..';
import { HealthCheckError } from '../../health-check/health-check.error';
import {
checkPackages,
isError,
Expand Down
4 changes: 2 additions & 2 deletions lib/health-indicator/microservice/microservice.health.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { HealthCheckError } from '../../health-check/health-check.error';
import { Injectable, Scope } from '@nestjs/common';
import * as NestJSMicroservices from '@nestjs/microservices';
import { HealthIndicator, HealthIndicatorResult } from '../';
import { TimeoutError } from '../../errors';
import { HealthCheckError } from '../../health-check/health-check.error';
import {
checkPackages,
promiseTimeout,
TimeoutError as PromiseTimeoutError,
PropType,
isError,
} from '../../utils';
import { HealthIndicator, HealthIndicatorResult } from '../';

// Since @nestjs/microservices is lazily loaded we are not able to use
// its types. It would end up in the d.ts file if we would use the types.
Expand Down
10 changes: 5 additions & 5 deletions lib/terminus.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { DynamicModule, Module } from '@nestjs/common';
import { DiskUsageLibProvider } from './health-indicator/disk/disk-usage-lib.provider';
import { HEALTH_INDICATORS } from './health-indicator/health-indicators.provider';
import { HealthCheckService } from './health-check';
import { HealthCheckExecutor } from './health-check/health-check-executor.service';
import { ERROR_LOGGERS } from './health-check/error-logger/error-loggers.provider';
import { getErrorLoggerProvider } from './health-check/error-logger/error-logger.provider';
import { TerminusModuleOptions } from './terminus-options.interface';
import { ERROR_LOGGERS } from './health-check/error-logger/error-loggers.provider';
import { HealthCheckExecutor } from './health-check/health-check-executor.service';
import { getLoggerProvider } from './health-check/logger/logger.provider';
import { DiskUsageLibProvider } from './health-indicator/disk/disk-usage-lib.provider';
import { HEALTH_INDICATORS } from './health-indicator/health-indicators.provider';
import { TerminusModuleOptions } from './terminus-options.interface';

const providers = [
...ERROR_LOGGERS,
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/is-error.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AxiosError } from '../errors/axios.error';
import { HealthCheckError } from '../';
import { AxiosError } from '../errors/axios.error';

export function isHealthCheckError(err: any): err is HealthCheckError {
return err?.isHealthCheckError;
Expand Down
Loading

0 comments on commit 29bb4bd

Please sign in to comment.