Skip to content

Commit c5f14eb

Browse files
committed
Fix two instances of floating promises
1 parent 29a392b commit c5f14eb

File tree

4 files changed

+32
-7
lines changed

4 files changed

+32
-7
lines changed

.eslintrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@ module.exports = {
2121
'@typescript-eslint/explicit-function-return-type': 'off',
2222
'@typescript-eslint/explicit-module-boundary-types': 'off',
2323
'@typescript-eslint/no-explicit-any': 'off',
24+
"@typescript-eslint/no-floating-promises": ["error"]
2425
},
2526
};

src/flow/flow.controller.ts

+20
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,26 @@ export class FlowController {
135135
});
136136
}
137137

138+
// @UseGuards(AuthGuard)
139+
// @ApiResponse({ status: 200, description: 'All your voting data is removed' })
140+
// @Get('/insertImage')
141+
// async insertImages(@Req() { userId }: AuthedReq) {
142+
// const collections = await this.prismaService.collection.findMany({
143+
// select: { id: true, name: true },
144+
// });
145+
146+
// await Promise.all(
147+
// collections.map(async (collection) => {
148+
// await this.prismaService.collection.update({
149+
// where: { id: collection.id },
150+
// data: {
151+
// image: `https://wsrv.nl/?url=pairwise.cupofjoy.store/rpgf2/${collection.name}.png`,
152+
// },
153+
// });
154+
// }),
155+
// );
156+
// }
157+
138158
// @Get('/correctInvalid')
139159
// async checkForInvalid() {
140160
// const allInvalidVotes = await this.prismaService.projectVote.findMany({

src/flow/flow.service.ts

+10-7
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class FlowService {
3535
project2Id: number,
3636
pickedId: number | null,
3737
) => {
38-
this.validateProjectVote(project1Id, project2Id, pickedId);
38+
await this.validateProjectVote(project1Id, project2Id, pickedId);
3939
const payload = {
4040
user_id: userId,
4141
project1_id: project1Id,
@@ -67,7 +67,7 @@ export class FlowService {
6767
collection2Id: number,
6868
pickedId: number | null,
6969
) => {
70-
this.validateCollectionVote(collection1Id, collection2Id, pickedId);
70+
await this.validateCollectionVote(collection1Id, collection2Id, pickedId);
7171
const payload = {
7272
user_id: userId,
7373
collection1_id: collection1Id,
@@ -401,22 +401,25 @@ export class FlowService {
401401
getCollectionSubunitType = async (
402402
collectionId?: number,
403403
): Promise<'project' | 'collection'> => {
404-
const collections = await this.prismaService.collection.findFirst({
404+
const collection = await this.prismaService.collection.findFirst({
405405
where: { parent_collection_id: collectionId },
406406
});
407407

408-
const projects = collectionId
408+
const project = collectionId
409409
? await this.prismaService.project.findFirst({
410410
where: { collection_id: collectionId },
411411
})
412412
: null;
413413

414-
if (collections && projects)
415-
throw new Error(
414+
if (collection && project)
415+
throw new InternalServerErrorException(
416416
'A collection can not have both projects and collections as its subunits',
417417
);
418418

419-
if (collections) return 'collection';
419+
if (!collection && !project)
420+
throw new BadRequestException('Invalid collection id');
421+
422+
if (collection) return 'collection';
420423
return 'project';
421424
};
422425

src/main.ts

+1
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ async function bootstrap() {
3939

4040
await app.listen(process.env.PORT || 7070, '0.0.0.0');
4141
}
42+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
4243
bootstrap();

0 commit comments

Comments
 (0)