Skip to content

Commit fce3639

Browse files
authored
156 build pagination (#86)
* Builds pagination added
1 parent 57d83b4 commit fce3639

24 files changed

+2704
-6412
lines changed

package-lock.json

Lines changed: 2295 additions & 6149 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"@nestjs/platform-socket.io": "^7.4.2",
3131
"@nestjs/swagger": "^4.5.12",
3232
"@nestjs/websockets": "^7.4.2",
33-
"@prisma/client": "^2.8.1",
33+
"@prisma/client": "2.12.1",
3434
"bcryptjs": "^2.4.3",
3535
"class-transformer": "^0.3.1",
3636
"class-validator": "^0.12.2",
@@ -52,7 +52,7 @@
5252
"@nestjs/cli": "^7.4.1",
5353
"@nestjs/schematics": "^7.0.1",
5454
"@nestjs/testing": "^7.4.2",
55-
"@prisma/cli": "^2.8.1",
55+
"@prisma/cli": "2.12.1",
5656
"@types/bcryptjs": "^2.4.2",
5757
"@types/express": "^4.17.7",
5858
"@types/jest": "26.0.14",

prisma/package-lock.json

Lines changed: 29 additions & 59 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

prisma/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
"license": "UNLICENSED",
88
"scripts": {},
99
"dependencies": {
10-
"@prisma/client": "^2.8.1",
10+
"@prisma/client": "2.12.1",
1111
"bcryptjs": "^2.4.3",
1212
"uuid-apikey": "^1.4.6"
1313
},
1414
"devDependencies": {
15-
"@prisma/cli": "^2.8.1",
15+
"@prisma/cli": "2.12.1",
1616
"@types/bcryptjs": "^2.4.2",
1717
"@types/uuid-apikey": "^1.4.0",
1818
"ts-node": "^8.10.2",

prisma/schema.prisma

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
generator client {
2-
provider = "prisma-client-js"
3-
previewFeatures = ["atomicNumberOperations"]
2+
provider = "prisma-client-js"
43
}
54

65
datasource db {

src/auth/guards/api.guard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export class ApiGuard implements CanActivate {
99
async canActivate(context: ExecutionContext): Promise<boolean> {
1010
const request: Request = context.switchToHttp().getRequest();
1111
try {
12-
const user = await this.prismaService.user.findOne({
12+
const user = await this.prismaService.user.findUnique({
1313
where: { apiKey: request.header('apiKey') },
1414
});
1515
return !!user;

src/auth/jwt.strategy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class JwtStrategy extends PassportStrategy(Strategy) {
1616
}
1717

1818
async validate(payload: JwtPayload, done: VerifiedCallback) {
19-
const user = await this.prismaService.user.findOne({
19+
const user = await this.prismaService.user.findUnique({
2020
where: { email: payload.email }
2121
});
2222

src/builds/builds.controller.ts

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
import { Controller, Get, UseGuards, Post, Body, Param, ParseUUIDPipe, Delete, Query, Patch } from '@nestjs/common';
1+
import {
2+
Controller,
3+
Get,
4+
UseGuards,
5+
Post,
6+
Body,
7+
Param,
8+
ParseUUIDPipe,
9+
Delete,
10+
Query,
11+
Patch,
12+
ParseIntPipe,
13+
ParseBoolPipe,
14+
} from '@nestjs/common';
215
import { BuildsService } from './builds.service';
316
import { JwtAuthGuard } from '../auth/guards/auth.guard';
417
import { ApiBearerAuth, ApiTags, ApiSecurity, ApiOkResponse } from '@nestjs/swagger';
@@ -7,18 +20,31 @@ import { ApiGuard } from '../auth/guards/api.guard';
720
import { Build } from '@prisma/client';
821
import { BuildDto } from './dto/build.dto';
922
import { MixedGuard } from '../auth/guards/mixed.guard';
23+
import { PaginatedBuildDto } from './dto/build-paginated.dto';
1024

1125
@Controller('builds')
1226
@ApiTags('builds')
1327
export class BuildsController {
1428
constructor(private buildsService: BuildsService) {}
1529

1630
@Get()
17-
@ApiOkResponse({ type: [BuildDto] })
31+
@ApiOkResponse({ type: PaginatedBuildDto })
1832
@ApiBearerAuth()
1933
@UseGuards(JwtAuthGuard)
20-
get(@Query('projectId', new ParseUUIDPipe()) projectId: string): Promise<BuildDto[]> {
21-
return this.buildsService.findMany(projectId);
34+
get(
35+
@Query('projectId', new ParseUUIDPipe()) projectId: string,
36+
@Query('take', new ParseIntPipe()) take: number,
37+
@Query('skip', new ParseIntPipe()) skip: number
38+
): Promise<PaginatedBuildDto> {
39+
return this.buildsService.findMany(projectId, take, skip);
40+
}
41+
42+
@Get(':id')
43+
@ApiOkResponse({ type: BuildDto })
44+
@ApiBearerAuth()
45+
@UseGuards(JwtAuthGuard)
46+
getDetails(@Param('id', new ParseUUIDPipe()) id: string): Promise<BuildDto> {
47+
return this.buildsService.findOne(id);
2248
}
2349

2450
@Delete(':id')
@@ -44,4 +70,15 @@ export class BuildsController {
4470
stop(@Param('id', new ParseUUIDPipe()) id: string): Promise<BuildDto> {
4571
return this.buildsService.stop(id);
4672
}
73+
74+
@Patch(':id/approve')
75+
@ApiOkResponse({ type: BuildDto })
76+
@ApiBearerAuth()
77+
@UseGuards(JwtAuthGuard)
78+
approve(
79+
@Param('id', new ParseUUIDPipe()) id: string,
80+
@Query('merge', new ParseBoolPipe()) merge: boolean
81+
): Promise<BuildDto> {
82+
return this.buildsService.approve(id, merge);
83+
}
4784
}

0 commit comments

Comments
 (0)