Skip to content

Commit

Permalink
fix(app): remove automatic status endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
etienne-bechara committed Nov 11, 2024
1 parent 470cad0 commit 644bc64
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 118 deletions.
12 changes: 0 additions & 12 deletions source/app/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
import { Controller, Get, HttpCode, HttpStatus } from '@nestjs/common';
import { ApiExcludeController } from '@nestjs/swagger';

import { AppStatusDto } from './app.dto.out';
import { AppService } from './app.service';

@Controller()
@ApiExcludeController()
export class AppController {

public constructor(
private readonly appService: AppService,
) { }

@Get()
@HttpCode(HttpStatus.NO_CONTENT)
public get(): void {
return;
}

@Get('status')
public getStatus(): AppStatusDto {
return this.appService.getStatus();
}

}
40 changes: 0 additions & 40 deletions source/app/app.dto.out.ts

This file was deleted.

2 changes: 0 additions & 2 deletions source/app/app.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ export interface AppOptions extends ModuleMetadata {
disableAll?: boolean;
/** Disables automatically importing `*.module.ts` files. */
disableScan?: boolean;
/** Disables status endpoints `/` and `/status`. */
disableStatus?: boolean;
/** Disables built-in exception filter `app.filter.ts`. */
disableFilter?: boolean;
/** Disables validation pipe which applies `class-validator` decorators. */
Expand Down
17 changes: 1 addition & 16 deletions source/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ export class AppModule {
this.options.disableLogs = true;
this.options.disableMetrics = true;
this.options.disableScan = true;
this.options.disableStatus = true;
this.options.disableValidator = true;
}

Expand Down Expand Up @@ -271,7 +270,7 @@ export class AppModule {
return {
module: AppModule,
imports: this.buildModules('imports'),
controllers: this.buildControllers(),
controllers: [ ...this.options.controllers, AppController ],
providers: this.buildProviders(),
exports: [
AppConfig,
Expand Down Expand Up @@ -355,20 +354,6 @@ export class AppModule {
return preloadedModules;
}

/**
* Adds app controller with machine status information.
*/
private static buildControllers(): any[] {
const { disableStatus, controllers } = this.options;
const preloadedControllers = [ ];

if (!disableStatus) {
preloadedControllers.push(AppController);
}

return [ ...preloadedControllers, ...controllers ];
}

/**
* Adds exception filter, serializer, timeout and validation pipe.
*/
Expand Down
21 changes: 0 additions & 21 deletions source/app/app.service.spec.ts

This file was deleted.

26 changes: 0 additions & 26 deletions source/app/app.service.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { HttpStatus, Injectable } from '@nestjs/common';
import { SpanStatusCode } from '@opentelemetry/api';
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
import os from 'os';

import { ContextService } from '../context/context.service';
import { HttpMethod } from '../http/http.enum';
import { MetricService } from '../metric/metric.service';
import { AppStatusDto } from './app.dto.out';
import { AppTraffic } from './app.enum';

@Injectable()
Expand All @@ -17,30 +15,6 @@ export class AppService {
private readonly metricService: MetricService,
) { }

/**
* Reads data regarding current runtime and network.
*/
public getStatus(): AppStatusDto {
return {
system: {
version: os.version(),
type: os.type(),
release: os.release(),
architecture: os.arch(),
endianness: os.endianness(),
uptime: os.uptime(),
},
memory: {
total: os.totalmem(),
free: os.freemem(),
},
cpus: os.cpus(),
network: {
interfaces: os.networkInterfaces(),
},
};
}

/**
* Register logs, metrics and tracing of inbound request.
*
Expand Down
2 changes: 1 addition & 1 deletion source/trace/trace.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class TraceService {
const traceUrl = this.buildTraceUrl();

if (!this.appConfig.APP_OPTIONS.disableTraces && !traceUrl) {
this.logService.warning('Trace disable due to missing URL');
this.logService.warning('Trace disabled due to missing URL');
this.appConfig.APP_OPTIONS.disableTraces = true;
}

Expand Down

0 comments on commit 644bc64

Please sign in to comment.