Skip to content

Commit

Permalink
Players Endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
csuvajit committed Mar 2, 2024
1 parent 58ee0c4 commit b88338a
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 11 deletions.
4 changes: 3 additions & 1 deletion apps/service-auth/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ import { AuthModule } from './auth/auth.module';
import { ClansModule } from './clans/clans.module';
import { GuildsModule } from './guilds/guilds.module';
import { LinksModule } from './links/links.module';
import { PlayersModule } from './players/players.module';

@Module({
imports: [
ConfigModule.forRoot({ isGlobal: true }),
MongoDbModule,
RedisModule,
ClansModule,
AuthModule,
ClansModule,
GuildsModule,
LinksModule,
PlayersModule,
],
controllers: [],
providers: [],
Expand Down
21 changes: 17 additions & 4 deletions apps/service-auth/src/clans/clans.controller.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
import { JwtAuthGuard } from '@app/auth';
import { Controller, Get, UseGuards } from '@nestjs/common';
import { Controller, Get, Param, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { ClansService } from './clans.service';

@ApiTags('CLANS')
@ApiBearerAuth()
@Controller('/clans')
@UseGuards(JwtAuthGuard)
export class ClansController {
@Get()
getHello() {
return {};
constructor(private clansService: ClansService) {}

@Get('/:clanTag/capital-contribution')
getCapitalContribution(@Param('clanTag') clanTag: string) {
return this.clansService.getCapitalContribution(clanTag);
}

@Get('/:clanTag/linked-members')
getLinkedMembers(@Param('clanTag') clanTag: string) {
return this.clansService.getCapitalContribution(clanTag);
}

@Get('/:clanTag/wars/:warId')
getClanWar(@Param('clanTag') clanTag: string, @Param('warId') warId: string) {
return this.clansService.getClanWar(clanTag, warId);
}
}
4 changes: 2 additions & 2 deletions apps/service-auth/src/clans/clans.module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Module } from '@nestjs/common';
import { ClansService } from './clans.service';
import { ClansController } from './clans.controller';
import { ClansService } from './clans.service';

@Module({
providers: [ClansService],
controllers: [ClansController],
providers: [ClansService],
})
export class ClansModule {}
12 changes: 11 additions & 1 deletion apps/service-auth/src/clans/clans.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
import { Injectable } from '@nestjs/common';

@Injectable()
export class ClansService {}
export class ClansService {
constructor() {}

getCapitalContribution(clanTag: string) {
return { clanTag };
}

getClanWar(clanTag: string, warId: string) {
return { clanTag, warId };
}
}
3 changes: 2 additions & 1 deletion apps/service-auth/src/links/links.controller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CurrentUser, JwtAuthGuard, JwtUser } from '@app/auth';
import { Body, Controller, Delete, Get, Param, Post, UseGuards } from '@nestjs/common';
import { Body, Controller, Delete, Get, HttpCode, Param, Post, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { BulkLinksDto } from './dto/bulk-links.dto';
import { CreateLinkInput } from './dto/create-links.dto';
Expand Down Expand Up @@ -29,6 +29,7 @@ export class LinksController {
}

@Post('/bulk')
@HttpCode(200)
getLinks(@Body() body: BulkLinksDto) {
return this.linksService.getLinks(body.input);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/service-auth/src/links/links.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ export class LinksService {
}

getLinks(playerTags: string[]) {
return [playerTags];
return playerTags;
}
}
2 changes: 1 addition & 1 deletion apps/service-auth/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async function bootstrap() {
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('/', app, document);

app.useGlobalPipes(new ValidationPipe({ transform: true }));
app.useGlobalPipes(new ValidationPipe());

const port = process.env.PORT || 8081;
await app.listen(port);
Expand Down
18 changes: 18 additions & 0 deletions apps/service-auth/src/players/players.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { JwtAuthGuard } from '@app/auth';
import { Controller, Get, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { PlayersService } from './players.service';

@ApiTags('PLAYERS')
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Controller('/players')
export class PlayersController {
constructor(private playersService: PlayersService) {}

@Get('/:playerTag/clan-wars')
getWarHistory() {}

@Get('/:playerTag/clan-war-league-stats')
getClanWarLeagueStats() {}
}
9 changes: 9 additions & 0 deletions apps/service-auth/src/players/players.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { PlayersController } from './players.controller';
import { PlayersService } from './players.service';

@Module({
controllers: [PlayersController],
providers: [PlayersService],
})
export class PlayersModule {}
4 changes: 4 additions & 0 deletions apps/service-auth/src/players/players.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Injectable } from '@nestjs/common';

@Injectable()
export class PlayersService {}

0 comments on commit b88338a

Please sign in to comment.