Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/.hg/store/**": true
}
}
1,604 changes: 916 additions & 688 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@nestjs/common": "^7.3.2",
"@nestjs/common": "^7.4.2",
"@nestjs/config": "^0.5.0",
"@nestjs/core": "^7.3.2",
"@nestjs/core": "^7.4.2",
"@nestjs/jwt": "^7.1.0",
"@nestjs/passport": "^7.1.0",
"@nestjs/platform-express": "^7.3.2",
"@nestjs/platform-socket.io": "^7.3.2",
"@nestjs/platform-express": "^7.4.2",
"@nestjs/platform-socket.io": "^7.4.2",
"@nestjs/swagger": "^4.5.12",
"@nestjs/websockets": "^7.3.2",
"@prisma/client": "^2.2.2",
"@nestjs/websockets": "^7.4.2",
"@prisma/client": "^2.4.1",
"bcryptjs": "^2.4.3",
"class-transformer": "^0.3.1",
"class-validator": "^0.12.2",
Expand All @@ -44,15 +44,15 @@
"pngjs": "^5.0.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^6.6.0",
"rxjs": "^6.6.2",
"swagger-ui-express": "^4.1.4",
"uuid-apikey": "^1.4.6"
},
"devDependencies": {
"@nestjs/cli": "^7.4.1",
"@nestjs/schematics": "^7.0.1",
"@nestjs/testing": "^7.3.2",
"@prisma/cli": "^2.2.2",
"@nestjs/testing": "^7.4.2",
"@prisma/cli": "^2.4.1",
"@types/bcryptjs": "^2.4.2",
"@types/express": "^4.17.7",
"@types/jest": "26.0.5",
Expand All @@ -61,19 +61,19 @@
"@types/passport-local": "^1.0.33",
"@types/pixelmatch": "^5.2.1",
"@types/pngjs": "^3.4.2",
"@types/socket.io": "^2.1.10",
"@types/socket.io": "^2.1.11",
"@types/supertest": "^2.0.10",
"@types/uuid-apikey": "^1.4.0",
"@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.34.0",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.22.0",
"jest": "^26.1.0",
"jest": "^26.3.0",
"prettier": "^2.0.5",
"supertest": "^4.0.2",
"ts-jest": "^26.1.3",
"ts-loader": "^8.0.1",
"ts-jest": "^26.2.0",
"ts-loader": "^8.0.2",
"ts-node": "^8.10.2",
"tsconfig-paths": "^3.9.0",
"typescript": "^3.9.7"
Expand Down
39 changes: 39 additions & 0 deletions prisma/migrations/20200812213545-build-run-status/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Migration `20200812213545-build-run-status`

This migration has been generated by Pavel Strunkin at 8/12/2020, 9:35:45 PM.
You can check out the [state of the schema](./schema.prisma) after the migration.

## Database Steps

```sql
ALTER TABLE "public"."Build" ADD COLUMN "isRunning" boolean ;
```

## Changes

```diff
diff --git schema.prisma schema.prisma
migration 20200728221159-zero-diff-tolerance..20200812213545-build-run-status
--- datamodel.dml
+++ datamodel.dml
@@ -3,9 +3,9 @@
}
datasource db {
provider = "postgresql"
- url = "***"
+ url = "***"
}
model Build {
id String @default(uuid()) @id
@@ -18,8 +18,9 @@
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())
user User? @relation(fields: [userId], references: [id])
userId String?
+ isRunning Boolean?
}
model Project {
id String @default(uuid()) @id
```


117 changes: 117 additions & 0 deletions prisma/migrations/20200812213545-build-run-status/schema.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = "***"
}

model Build {
id String @default(uuid()) @id
number Int?
branchName String?
status String?
testRuns TestRun[]
projectId String
project Project @relation(fields: [projectId], references: [id])
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())
user User? @relation(fields: [userId], references: [id])
userId String?
isRunning Boolean?
}

model Project {
id String @default(uuid()) @id
name String
mainBranchName String @default("master")
builds Build[]
testVariations TestVariation[]
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())

@@unique([name])
}

model TestRun {
id String @default(uuid()) @id
imageName String
diffName String?
diffPercent Float?
diffTollerancePercent Float @default(0)
pixelMisMatchCount Int?
status TestStatus
buildId String
build Build @relation(fields: [buildId], references: [id])
testVariationId String
testVariation TestVariation @relation(fields: [testVariationId], references: [id])
merge Boolean @default(false)
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())
// Test variation data
name String @default("")
browser String?
device String?
os String?
viewport String?
baselineName String?
ignoreAreas String @default("[]")
comment String?
baseline Baseline?
branchName String @default("master")
baselineBranchName String?
}

model TestVariation {
id String @default(uuid()) @id
name String
branchName String @default("master")
browser String?
device String?
os String?
viewport String?
baselineName String?
ignoreAreas String @default("[]")
projectId String
project Project @relation(fields: [projectId], references: [id])
testRuns TestRun[]
baselines Baseline[]
comment String?
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())

@@unique([name, browser, device, os, viewport, branchName])
}

model Baseline {
id String @default(uuid()) @id
baselineName String
testVariationId String
testVariation TestVariation @relation(fields: [testVariationId], references: [id])
testRunId String?
testRun TestRun? @relation(fields: [testRunId], references: [id])
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())
}

model User {
id String @default(uuid()) @id
email String @unique
password String
firstName String?
lastName String?
apiKey String @unique
isActive Boolean @default(true)
builds Build[]
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())
}

enum TestStatus {
failed
new
ok
unresolved
approved
}
12 changes: 12 additions & 0 deletions prisma/migrations/20200812213545-build-run-status/steps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": "0.3.14-fixed",
"steps": [
{
"tag": "CreateField",
"model": "Build",
"field": "isRunning",
"type": "Boolean",
"arity": "Optional"
}
]
}
3 changes: 2 additions & 1 deletion prisma/migrations/migrate.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
20200627134248-comment-added
20200707182652-project-name-unique-constraint
20200715232608-branch-strategy
20200728221159-zero-diff-tolerance
20200728221159-zero-diff-tolerance
20200812213545-build-run-status
24 changes: 12 additions & 12 deletions prisma/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions prisma/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"uuid-apikey": "^1.4.6"
},
"devDependencies": {
"@prisma/cli": "^2.2.2",
"@prisma/cli": "^2.4.1",
"@types/bcryptjs": "^2.4.2",
"@types/uuid-apikey": "^1.4.0",
"ts-node": "^8.8.2",
"typescript": "^3.7.4"
"ts-node": "^8.10.2",
"typescript": "^3.9.7"
}
}
1 change: 1 addition & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ model Build {
createdAt DateTime @default(now())
user User? @relation(fields: [userId], references: [id])
userId String?
isRunning Boolean?
}

model Project {
Expand Down
6 changes: 3 additions & 3 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ const prisma = new PrismaClient({
});

async function seed() {
await prisma.connect();
await prisma.$connect();
console.log('Seeding default data...');
await Promise.all([createDefaultUser(), createDefaultProject()]);
await prisma.disconnect();
await prisma.$disconnect();
}

seed()
.catch((e) => console.error('e', e))
.finally(async () => await prisma.disconnect());
.finally(async () => await prisma.$disconnect());

async function createDefaultUser() {
const userList = await prisma.user.findMany();
Expand Down
5 changes: 3 additions & 2 deletions src/auth/auth.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { JwtStrategy } from './jwt.strategy';
import { ApiGuard } from './guards/api.guard';
import { ConfigService } from '@nestjs/config';
import { PrismaService } from '../prisma/prisma.service';
import { JwtAuthGuard } from './guards/auth.guard';

@Module({
imports: [
Expand All @@ -20,7 +21,7 @@ import { PrismaService } from '../prisma/prisma.service';
inject: [ConfigService],
}),
],
providers: [AuthService, JwtStrategy, ApiGuard, PrismaService],
exports: [AuthService],
providers: [AuthService, JwtStrategy, ApiGuard, JwtAuthGuard, PrismaService],
exports: [AuthService, ApiGuard, JwtAuthGuard],
})
export class AuthModule {}
21 changes: 21 additions & 0 deletions src/auth/guards/mixed.guard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ExecutionContext, Injectable, CanActivate } from '@nestjs/common';
import { ApiGuard } from './api.guard';
import { JwtAuthGuard } from './auth.guard';

@Injectable()
export class MixedGuard implements CanActivate {
constructor(private readonly apiGuard: ApiGuard, private readonly authGuard: JwtAuthGuard) {}

async canActivate(context: ExecutionContext): Promise<boolean> {
let jwtAuth = false;
try {
jwtAuth = (await this.authGuard.canActivate(context)) as boolean;
} catch (err) {}

let apiAuth = false;
try {
apiAuth = await this.apiGuard.canActivate(context);
} catch (err) {}
return jwtAuth || apiAuth;
}
}
Loading