diff --git a/src/api/public/public-api.module.ts b/src/api/public/public-api.module.ts index 442ac0b46..c7239f497 100644 --- a/src/api/public/public-api.module.ts +++ b/src/api/public/public-api.module.ts @@ -1,5 +1,6 @@ import { Module } from '@nestjs/common'; import { HistoryModule } from '../../history/history.module'; +import { MonitoringModule } from '../../monitoring/monitoring.module'; import { NotesModule } from '../../notes/notes.module'; import { RevisionsModule } from '../../revisions/revisions.module'; import { UsersModule } from '../../users/users.module'; @@ -9,7 +10,13 @@ import { MediaController } from './media/media.controller'; import { MonitoringController } from './monitoring/monitoring.controller'; @Module({ - imports: [UsersModule, HistoryModule, NotesModule, RevisionsModule], + imports: [ + UsersModule, + HistoryModule, + NotesModule, + RevisionsModule, + MonitoringModule, + ], controllers: [ MeController, NotesController, diff --git a/src/app.module.ts b/src/app.module.ts index 768df01a8..60821e71a 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -6,6 +6,7 @@ import { UsersModule } from './users/users.module'; import { RevisionsModule } from './revisions/revisions.module'; import { AuthorsModule } from './authors/authors.module'; import { HistoryModule } from './history/history.module'; +import { MonitoringModule } from './monitoring/monitoring.module'; @Module({ imports: [ @@ -21,6 +22,7 @@ import { HistoryModule } from './history/history.module'; AuthorsModule, PublicApiModule, HistoryModule, + MonitoringModule, ], controllers: [], providers: [], diff --git a/src/monitoring/monitoring.module.ts b/src/monitoring/monitoring.module.ts new file mode 100644 index 000000000..b94af54d4 --- /dev/null +++ b/src/monitoring/monitoring.module.ts @@ -0,0 +1,8 @@ +import { Module } from '@nestjs/common'; +import { MonitoringService } from './monitoring.service'; + +@Module({ + providers: [MonitoringService], + exports: [MonitoringService], +}) +export class MonitoringModule {} diff --git a/src/monitoring/monitoring.service.spec.ts b/src/monitoring/monitoring.service.spec.ts new file mode 100644 index 000000000..9264924bc --- /dev/null +++ b/src/monitoring/monitoring.service.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { MonitoringService } from './monitoring.service'; + +describe('MonitoringService', () => { + let service: MonitoringService; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [MonitoringService], + }).compile(); + + service = module.get(MonitoringService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/src/monitoring/monitoring.service.ts b/src/monitoring/monitoring.service.ts new file mode 100644 index 000000000..bec60140c --- /dev/null +++ b/src/monitoring/monitoring.service.ts @@ -0,0 +1,27 @@ +import { Injectable } from '@nestjs/common'; +import { ServerStatusDto } from './server-status.dto'; + +@Injectable() +export class MonitoringService { + getServerStatus(): ServerStatusDto { + return { + connectionSocketQueueLenght: 0, + destictOnlineUsers: 0, + disconnectSocketQueueLength: 0, + distictOnlineRegisteredUsers: 0, + isConnectionBusy: false, + isDisconnectBusy: false, + notesCount: 0, + onlineNotes: 0, + onlineRegisteredUsers: 0, + onlineUsers: 0, + registeredUsers: 0, + serverVersion: { + major: 2, + minor: 0, + patch: 0, + preRelease: 'dev', + }, + }; + } +} diff --git a/src/monitoring/server-status.dto.ts b/src/monitoring/server-status.dto.ts new file mode 100644 index 000000000..7ea4b4afd --- /dev/null +++ b/src/monitoring/server-status.dto.ts @@ -0,0 +1,20 @@ +export class ServerStatusDto { + serverVersion: { + major: number; + minor: number; + patch: number; + preRelease?: string; + commit?: string; + }; + onlineNotes: number; + onlineUsers: number; + destictOnlineUsers: number; + notesCount: number; + registeredUsers: number; + onlineRegisteredUsers: number; + distictOnlineRegisteredUsers: number; + isConnectionBusy: boolean; + connectionSocketQueueLenght: number; + isDisconnectBusy: boolean; + disconnectSocketQueueLength: number; +}