From c4f1a9313647d92ca307dd014167379c8cac12c9 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 21 Sep 2020 16:16:31 +0200 Subject: [PATCH] feat(server): add public API --- .vscode/settings.json | 1 + server/src/app/app.module.ts | 3 ++- .../app/controllers/teamspeak.controller.ts | 27 +++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 server/src/app/controllers/teamspeak.controller.ts diff --git a/.vscode/settings.json b/.vscode/settings.json index e9c22ae..b121d90 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -17,6 +17,7 @@ "fastify", "ijmap", "nestjs", + "populatedchannel", "tsviewer", "uglifycss" ], diff --git a/server/src/app/app.module.ts b/server/src/app/app.module.ts index 419d2dc..c1afee6 100644 --- a/server/src/app/app.module.ts +++ b/server/src/app/app.module.ts @@ -1,10 +1,11 @@ import { AppController } from './controllers/app.controller'; import { Module } from '@nestjs/common'; +import { TeamspeakController } from './controllers/teamspeak.controller'; import { TeamspeakService } from './services/teamspeak.service'; @Module({ providers: [TeamspeakService], - controllers: [AppController], + controllers: [AppController, TeamspeakController], exports: [], }) export class ApplicationModule { } \ No newline at end of file diff --git a/server/src/app/controllers/teamspeak.controller.ts b/server/src/app/controllers/teamspeak.controller.ts new file mode 100644 index 0000000..1402599 --- /dev/null +++ b/server/src/app/controllers/teamspeak.controller.ts @@ -0,0 +1,27 @@ +import { Controller, Get } from '@nestjs/common'; +import { ApiTags } from '@nestjs/swagger'; +import { IChannel } from '../interfaces/channel.interface'; +import { IClient } from '../interfaces/client.interface'; +import { IPopulatedChannel } from '../interfaces/populatedchannel.interface'; +import { TeamspeakService } from '../services/teamspeak.service'; + +@Controller('api') +@ApiTags('teamspeak') +export class TeamspeakController { + constructor(private teamspeakService: TeamspeakService) {} + + @Get('clients') + async getClients(): Promise { + return this.teamspeakService.getClients(); + } + + @Get('channels') + async getChannels(): Promise { + return this.teamspeakService.getChannels(); + } + + @Get('populatedChannelList') + async getPopulatedChannelList(): Promise { + return this.teamspeakService.getPopulatedChannelList(); + } +} \ No newline at end of file