Skip to content

Commit 98f3398

Browse files
committed
fix: return types
1 parent 0a36e7b commit 98f3398

File tree

7 files changed

+26
-17
lines changed

7 files changed

+26
-17
lines changed

src/links/dto/link-input.dto.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ export class LinksDto {
5050
}
5151

5252
export class MessageOkDto {
53-
message: string;
53+
@ApiProperty({ nullable: false, required: true })
54+
message?: string;
55+
56+
[key: string]: unknown;
5457
}
5558

5659
export class GetLinksInputDto {

src/rosters/rosters.controller.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { ApiBearerAuth } from '@nestjs/swagger';
1414
import { Request } from 'express';
1515
import { JwtAuthGuard, Roles, RolesGuard, UserRoles } from '../auth';
1616
import { RostersEntity } from '../db';
17+
import { MessageOkDto } from '../links/dto';
1718
import {
1819
RemoveMembersBulkInput,
1920
TransferRosterMembersDto,
@@ -35,7 +36,7 @@ export class RostersController {
3536
}
3637

3738
@Post('/:guildId/create')
38-
createRoster(@Param('guildId') guildId: string): unknown {
39+
createRoster(@Param('guildId') guildId: string): Promise<MessageOkDto> {
3940
return Promise.resolve({ guildId });
4041
}
4142

@@ -48,23 +49,23 @@ export class RostersController {
4849
}
4950

5051
@Patch('/:guildId/:rosterId')
51-
updateRoster(@Param('rosterId') rosterId: string): unknown {
52+
updateRoster(@Param('rosterId') rosterId: string): Promise<MessageOkDto> {
5253
return Promise.resolve({ rosterId });
5354
}
5455

5556
@Delete('/:guildId/:rosterId')
56-
deleteRoster(@Param('rosterId') rosterId: string, @Req() req: Request): unknown {
57+
deleteRoster(@Param('rosterId') rosterId: string, @Req() req: Request): Promise<MessageOkDto> {
5758
console.log(req.headers);
5859
return Promise.resolve({ rosterId });
5960
}
6061

6162
@Post('/:guildId/:rosterId/clone')
62-
cloneRoster(@Param('rosterId') rosterId: string): unknown {
63+
cloneRoster(@Param('rosterId') rosterId: string): Promise<MessageOkDto> {
6364
return Promise.resolve({ rosterId });
6465
}
6566

6667
@Put('/:guildId/:rosterId/members')
67-
addRosterMembers(@Param('rosterId') rosterId: string): unknown {
68+
addRosterMembers(@Param('rosterId') rosterId: string): Promise<MessageOkDto> {
6869
return Promise.resolve({ rosterId });
6970
}
7071

@@ -73,7 +74,7 @@ export class RostersController {
7374
@Param('rosterId') rosterId: string,
7475
@Param('guildId') guildId: string,
7576
@Body() body: RemoveMembersBulkInput,
76-
): unknown {
77+
): Promise<MessageOkDto> {
7778
return this.rostersService.deleteRosterMembers({
7879
rosterId,
7980
guildId,
@@ -82,7 +83,7 @@ export class RostersController {
8283
}
8384

8485
@Post('/:guildId/:rosterId/members/refresh')
85-
refreshRosterMembers(@Param('rosterId') rosterId: string): unknown {
86+
refreshRosterMembers(@Param('rosterId') rosterId: string): Promise<MessageOkDto> {
8687
return Promise.resolve({ rosterId });
8788
}
8889

src/tasks/tasks.controller.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { ApiExcludeRoute, ApiExcludeTypings, ApiKeyAuth } from '@app/decorators';
22
import { Controller, Post, UseGuards } from '@nestjs/common';
33
import { ApiKeyGuard } from '../auth/guards';
4+
import { MessageOkDto } from '../links/dto';
45
import { TasksService } from './tasks.service';
56

67
@Controller('/tasks')
@@ -12,22 +13,22 @@ export class TasksController {
1213
constructor(private tasksService: TasksService) {}
1314

1415
@Post('/bulk-add-legend-players')
15-
bulkAddLegendPlayers(): unknown {
16+
bulkAddLegendPlayers(): Promise<MessageOkDto> {
1617
return this.tasksService.bulkAddLegendPlayers();
1718
}
1819

1920
@Post('/seed-legend-players')
20-
seedLegendPlayers(): unknown {
21+
seedLegendPlayers(): Promise<MessageOkDto> {
2122
return this.tasksService.seedLegendPlayers();
2223
}
2324

2425
@Post('/migrate-legend-players')
25-
migrateLegendPlayers(): unknown {
26+
migrateLegendPlayers(): Promise<MessageOkDto> {
2627
return this.tasksService.migrateLegendPlayers();
2728
}
2829

2930
@Post('/update-legend-players')
30-
updateLegendPlayers(): unknown {
31+
updateLegendPlayers(): Promise<MessageOkDto> {
3132
return this.tasksService.updateLegendPlayers();
3233
}
3334
}

src/tasks/tasks.service.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ export class TasksService {
9595
lastId = docs[docs.length - 1]._id;
9696
if (lastId) await this.redis.set('player_update_progress', lastId.toHexString());
9797
}
98+
99+
return { message: 'Ok' };
98100
}
99101

100102
async bulkAddLegendPlayers() {

src/users/users.controller.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Controller, Get, UseGuards } from '@nestjs/common';
33
import { ApiBearerAuth } from '@nestjs/swagger';
44
import { JwtAuthGuard } from '../auth/guards';
55
import { UsersService } from './users.service';
6+
import { MessageOkDto } from '../links/dto';
67

78
@Controller('/users')
89
@ApiBearerAuth()
@@ -12,7 +13,7 @@ export class UsersController {
1213
constructor(private readonly usersService: UsersService) {}
1314

1415
@Get('/:userId')
15-
async getUser(): Promise<unknown> {
16+
async getUser(): Promise<MessageOkDto> {
1617
return Promise.resolve({ version: 'v1' });
1718
}
1819
}

src/webhook/webhook.controller.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
Req,
1111
} from '@nestjs/common';
1212
import { InteractionType } from 'discord-interactions';
13+
import { MessageOkDto } from '../links/dto';
1314
import { WebhookService } from './webhook.service';
1415

1516
@Controller('/webhook')
@@ -26,7 +27,7 @@ export class WebhookController {
2627
@Headers('X-Signature-Ed25519') signature: string,
2728
@Headers('X-Signature-Timestamp') timestamp: string,
2829
@Query('message') message: string,
29-
): unknown {
30+
): Promise<MessageOkDto> {
3031
return this.webhookService.handleDiscordInteractions({
3132
rawBody: req.rawBody as Buffer,
3233
interactionType: body.type as InteractionType,
@@ -37,7 +38,7 @@ export class WebhookController {
3738
}
3839

3940
@Post('/patreon/incoming')
40-
handlePatreonWebhook(): unknown {
41-
return {};
41+
handlePatreonWebhook(): Promise<MessageOkDto> {
42+
return Promise.resolve({ message: 'Ok' });
4243
}
4344
}

src/webhook/webhook.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class WebhookService {
2222
const discordPublicKey = this.configService.getOrThrow<string>('DISCORD_PUBLIC_KEY');
2323

2424
const isValidRequest = await verifyKey(rawBody, signature, timestamp, discordPublicKey);
25-
if (!isValidRequest) return new UnauthorizedException();
25+
if (!isValidRequest) throw new UnauthorizedException();
2626

2727
if (interactionType === InteractionType.PING) {
2828
return { type: InteractionResponseType.PONG };

0 commit comments

Comments
 (0)