feat(server): add public API
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Simon Giesel 2020-09-21 16:16:31 +02:00
parent 7726223698
commit c4f1a93136
3 changed files with 30 additions and 1 deletions

View file

@ -17,6 +17,7 @@
"fastify", "fastify",
"ijmap", "ijmap",
"nestjs", "nestjs",
"populatedchannel",
"tsviewer", "tsviewer",
"uglifycss" "uglifycss"
], ],

View file

@ -1,10 +1,11 @@
import { AppController } from './controllers/app.controller'; import { AppController } from './controllers/app.controller';
import { Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { TeamspeakController } from './controllers/teamspeak.controller';
import { TeamspeakService } from './services/teamspeak.service'; import { TeamspeakService } from './services/teamspeak.service';
@Module({ @Module({
providers: [TeamspeakService], providers: [TeamspeakService],
controllers: [AppController], controllers: [AppController, TeamspeakController],
exports: [], exports: [],
}) })
export class ApplicationModule { } export class ApplicationModule { }

View file

@ -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<IClient[]> {
return this.teamspeakService.getClients();
}
@Get('channels')
async getChannels(): Promise<IChannel[]> {
return this.teamspeakService.getChannels();
}
@Get('populatedChannelList')
async getPopulatedChannelList(): Promise<IPopulatedChannel[]> {
return this.teamspeakService.getPopulatedChannelList();
}
}