-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
364 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { IsNotEmpty } from 'class-validator'; | ||
|
||
export class LoginInput { | ||
@IsNotEmpty() | ||
passkey: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { JwtAuthGuard } from '@app/auth'; | ||
import { Controller, Get, UseGuards } from '@nestjs/common'; | ||
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger'; | ||
|
||
@ApiTags('CLANS') | ||
@ApiBearerAuth() | ||
@Controller('/clans') | ||
@UseGuards(JwtAuthGuard) | ||
export class ClansController { | ||
@Get() | ||
getHello() { | ||
return {}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { ClansService } from './clans.service'; | ||
import { ClansController } from './clans.controller'; | ||
|
||
@Module({}) | ||
@Module({ | ||
providers: [ClansService], | ||
controllers: [ClansController], | ||
}) | ||
export class ClansModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
|
||
@Injectable() | ||
export class ClansService {} |
32 changes: 32 additions & 0 deletions
32
apps/service-auth/src/guilds/dto/update-clan-categories.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { IsInt, IsNotEmpty, ValidateNested } from 'class-validator'; | ||
|
||
export class ReorderCategoriesInput { | ||
@IsNotEmpty() | ||
_id: string; | ||
|
||
@IsNotEmpty() | ||
name: string; | ||
|
||
@IsInt() | ||
order: number; | ||
|
||
@ValidateNested({ each: true }) | ||
clans: ReorderClansInput[]; | ||
} | ||
|
||
export class ReorderClansInput { | ||
@IsNotEmpty() | ||
_id: string; | ||
|
||
@IsInt() | ||
order: number; | ||
|
||
@IsNotEmpty() | ||
tag: string; | ||
|
||
@IsNotEmpty() | ||
name: string; | ||
|
||
@IsNotEmpty() | ||
guildId: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { JwtAuthGuard } from '@app/auth'; | ||
import { Body, Controller, Get, Param, Put, Query, UseGuards } from '@nestjs/common'; | ||
import { ApiBearerAuth, ApiBody, ApiTags } from '@nestjs/swagger'; | ||
import { ReorderCategoriesInput } from './dto/update-clan-categories.dto'; | ||
import { GuildsService } from './guilds.service'; | ||
|
||
@ApiTags('GUILDS') | ||
@Controller('/guilds') | ||
@ApiBearerAuth() | ||
@UseGuards(JwtAuthGuard) | ||
export class GuildsController { | ||
constructor(private guildsService: GuildsService) {} | ||
|
||
@Get('/:guildId/clans') | ||
getGuildMembers(@Param('guildId') guildId: string, @Query('q') q: string) { | ||
return this.guildsService.getMembers(guildId, q); | ||
} | ||
|
||
@Get('/:guildId/clans') | ||
getClans(@Param('guildId') guildId: string) { | ||
return this.guildsService.getClans(guildId); | ||
} | ||
|
||
@Get('/:guildId/clans-and-categories') | ||
getClansWithCategories(@Param('guildId') guildId: string) { | ||
return this.guildsService.getClans(guildId); | ||
} | ||
|
||
@Put('/:guildId/reorder-clans') | ||
@ApiBody({ type: ReorderCategoriesInput, isArray: true }) | ||
updateClansAndCategories(@Param('guildId') guildId: string, @Body() _: ReorderCategoriesInput[]) { | ||
return this.guildsService.getClans(guildId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { GuildsController } from './guilds.controller'; | ||
import { GuildsService } from './guilds.service'; | ||
|
||
@Module({ | ||
controllers: [GuildsController], | ||
providers: [GuildsService], | ||
}) | ||
export class GuildsModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
|
||
@Injectable() | ||
export class GuildsService { | ||
constructor() {} | ||
|
||
getMembers(guildId: string, q: string) { | ||
return [guildId, q]; | ||
} | ||
|
||
getClans(guildId: string) { | ||
return [guildId]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { ArrayMaxSize, IsString } from 'class-validator'; | ||
|
||
export class BulkLinksDto { | ||
@IsString({ each: true }) | ||
@ArrayMaxSize(1000) | ||
input: string[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { IsNotEmpty } from 'class-validator'; | ||
|
||
export class CreateLinkInput { | ||
@IsNotEmpty() | ||
name: string; | ||
|
||
@IsNotEmpty() | ||
tag: string; | ||
|
||
@IsNotEmpty() | ||
userId: string; | ||
|
||
@IsNotEmpty() | ||
username: string; | ||
|
||
@IsNotEmpty() | ||
displayName: string; | ||
|
||
@IsNotEmpty() | ||
discriminator: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { IsNotEmpty } from 'class-validator'; | ||
|
||
export class DeleteLinkInput { | ||
@IsNotEmpty() | ||
clanTag: string; | ||
|
||
@IsNotEmpty() | ||
playerTag: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { CurrentUser, JwtAuthGuard, JwtUser } from '@app/auth'; | ||
import { Body, Controller, Delete, Get, 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'; | ||
import { DeleteLinkInput } from './dto/delete-link.dto'; | ||
import { LinksService } from './links.service'; | ||
|
||
@ApiTags('LINKS') | ||
@Controller('/links') | ||
@ApiBearerAuth() | ||
@UseGuards(JwtAuthGuard) | ||
export class LinksController { | ||
constructor(private linksService: LinksService) {} | ||
|
||
@Post('/') | ||
async createLink(@Body() body: CreateLinkInput) { | ||
return this.linksService.createLink(body); | ||
} | ||
|
||
@Delete('/') | ||
async deleteLink(@CurrentUser() user: JwtUser, @Body() body: DeleteLinkInput) { | ||
return this.linksService.deleteLink(user.sub, body); | ||
} | ||
|
||
@Get('/:userIdOrTag') | ||
getLink(@Param('userIdOrTag') userIdOrTag: string) { | ||
return this.linksService.getLink(userIdOrTag); | ||
} | ||
|
||
@Post('/bulk') | ||
getLinks(@Body() body: BulkLinksDto) { | ||
return this.linksService.getLinks(body.input); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { LinksController } from './links.controller'; | ||
import { LinksService } from './links.service'; | ||
|
||
@Module({ | ||
controllers: [LinksController], | ||
providers: [LinksService], | ||
}) | ||
export class LinksModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { CreateLinkInput } from './dto/create-links.dto'; | ||
import { DeleteLinkInput } from './dto/delete-link.dto'; | ||
|
||
@Injectable() | ||
export class LinksService { | ||
createLink(input: CreateLinkInput) { | ||
return input; | ||
} | ||
|
||
deleteLink(userId: string, input: DeleteLinkInput) { | ||
return { userId, input }; | ||
} | ||
|
||
getLink(userIdOrTag: string) { | ||
return [userIdOrTag]; | ||
} | ||
|
||
getLinks(playerTags: string[]) { | ||
return [playerTags]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.