Skip to content

Commit

Permalink
hotfix: not valid contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
mdwitr0 committed Feb 22, 2024
1 parent 0223aeb commit 81a3da5
Show file tree
Hide file tree
Showing 33 changed files with 278 additions and 137 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Build and Push Docker Image

on:
push:
branches:
- main

jobs:
build_and_push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build and Push
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: mdwit/kp-api:latest
15 changes: 15 additions & 0 deletions infra/api/clustertunnel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: networking.cfargotunnel.com/v1alpha1
kind: ClusterTunnel
metadata:
name: kinopoisk-tunnel
namespace: kinopoisk
spec:
newTunnel:
name: kinopoisk-tunnel
size: 2
image: cloudflare/cloudflared:2023.8.2
cloudflare:
email: cloudflare-email #mdwit0r@gmail.com
domain: kinopoisk.dev
secret: cloudflare-secrets
accountId: cloudflare-id #20f5efa8d1c6c7b4369faee9fe46edb0
36 changes: 36 additions & 0 deletions infra/api/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: kp-api
namespace: kinopoisk
spec:
replicas: 5
selector:
matchLabels:
app: kp-api
template:
metadata:
labels:
app: kp-api
spec:
containers:
- name: kp-api
image: mdwit/kp-api:latest
ports:
- containerPort: 3000
envFrom:
- secretRef:
name: kp-api
- name: kp-api-sync
image: mdwit/kp-api:latest
imagePullPolicy: Always
ports:
- containerPort: 3000
env:
- name: NODE_ENV
value: sync
envFrom:
- secretRef:
name: kp-api
imagePullSecrets:
- name: regcred
12 changes: 12 additions & 0 deletions infra/api/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Service
metadata:
name: kp-api
namespace: kinopoisk
spec:
selector:
app: kp-api
ports:
- protocol: TCP
port: 3000
targetPort: 3000
29 changes: 29 additions & 0 deletions infra/api/sync-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: kp-sync
namespace: kinopoisk
spec:
replicas: 1
selector:
matchLabels:
app: kp-sync
template:
metadata:
labels:
app: kp-sync
spec:
containers:
- name: kp-api-sync
image: mdwit/kp-api:latest
imagePullPolicy: Always
ports:
- containerPort: 3000
env:
- name: NODE_ENV
value: sync
envFrom:
- secretRef:
name: kp-api
imagePullSecrets:
- name: regcred
14 changes: 14 additions & 0 deletions infra/api/tunnel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: networking.cfargotunnel.com/v1alpha1
kind: TunnelBinding
metadata:
name: kp-api
namespace: kinopoisk
subjects:
- kind: Service
name: kp-api-service
spec:
fqdn: api.kinopoisk.dev
protocol: https
target: http://kp-api-service.kinopoisk.svc.cluster.local:80
tunnelRef:
kind: ClusterTunnel
17 changes: 9 additions & 8 deletions src/common/models/award.model.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
import { Prop } from '@nestjs/mongoose';
import { ApiProperty } from '@nestjs/swagger';
import { ApiNullableProperty } from '../decorators/api-nullable-property.decorator';

export class NominationAward {
@ApiProperty()
@ApiNullableProperty()
@Prop()
title: string;

@ApiProperty()
@ApiNullableProperty()
@Prop()
year: number;
}

export class Nomination {
@ApiProperty({ type: () => NominationAward })
@ApiNullableProperty({ type: () => NominationAward })
@Prop()
award: NominationAward;

@ApiProperty()
@ApiNullableProperty()
@Prop()
title: string;
}

export class Award {
@ApiProperty({ type: () => Nomination })
@ApiNullableProperty({ type: () => Nomination })
@Prop()
nomination: Nomination;

@ApiProperty({ type: () => Boolean })
@ApiNullableProperty({ type: () => Boolean })
@Prop()
winning: boolean;

@ApiProperty()
@ApiNullableProperty()
@Prop()
updatedAt: Date;
@ApiProperty()
@ApiNullableProperty()
@Prop()
createdAt: Date;
}
4 changes: 0 additions & 4 deletions src/image/dto/update-image.dto.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/image/schemas/image.schema.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { HydratedDocument } from 'mongoose';
import { ApiNullableProperty } from '../../common/decorators/api-nullable-property.decorator';

export type ImageDocument = HydratedDocument<Image>;

Expand Down
5 changes: 3 additions & 2 deletions src/keyword/schemas/keyword.schema.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { HydratedDocument } from 'mongoose';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { ApiNullableProperty } from '../../common/decorators/api-nullable-property.decorator';

export class MovieFromKeyword {
@ApiPropertyOptional()
@ApiProperty()
@Prop()
id: number;
}
Expand All @@ -21,7 +22,7 @@ export class Keyword {
@Prop({ required: true, index: true })
id: number;

@ApiProperty()
@ApiNullableProperty()
@Prop()
title: string;

Expand Down
9 changes: 5 additions & 4 deletions src/list/schemas/list.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { HydratedDocument } from 'mongoose';
import { ShortImage } from '../../movie/schemas/movie.schema';
import { ApiProperty } from '@nestjs/swagger';
import { ApiNullableProperty } from '../../common/decorators/api-nullable-property.decorator';

export type ListDocument = HydratedDocument<List>;

Expand All @@ -17,22 +18,22 @@ export type ListDocument = HydratedDocument<List>;
toObject: { virtuals: true },
})
export class List {
@ApiProperty()
@ApiNullableProperty()
@Prop()
category: string;

@Prop()
name: string;

@ApiProperty()
@ApiNullableProperty()
@Prop({ unique: true })
slug: string;

@ApiProperty()
@ApiNullableProperty()
@Prop()
moviesCount: number;

@ApiProperty({ type: () => ShortImage })
@ApiNullableProperty({ type: () => ShortImage })
@Prop({ type: () => ShortImage })
cover: ShortImage;

Expand Down
1 change: 0 additions & 1 deletion src/movie/dto/create-movie.dto.ts

This file was deleted.

3 changes: 2 additions & 1 deletion src/movie/dto/get-possible-values.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsEnum } from 'class-validator';
import { ApiNullableProperty } from '../../common/decorators/api-nullable-property.decorator';

export enum DistinctFields {
GENRES = 'genres.name',
Expand All @@ -10,7 +11,7 @@ export enum DistinctFields {
}

export class GetPossibleValueDto {
@ApiProperty({ enum: DistinctFields })
@ApiNullableProperty({ enum: DistinctFields })
@IsEnum(DistinctFields)
field: DistinctFields;

Expand Down
2 changes: 1 addition & 1 deletion src/movie/dto/response/movie-award-docs.response.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PartialType } from '@nestjs/swagger';
import { AbstractDocsResponseDto } from '../../../common/dto/abstract/abstract-docs.response.dto';
import { MovieAward } from '../../schemas/movie-award.schema';

export class MovieAwardDocsResponseDto extends AbstractDocsResponseDto(PartialType(MovieAward)) {
export class MovieAwardDocsResponseDto extends AbstractDocsResponseDto(MovieAward) {
constructor(partial: Partial<MovieAwardDocsResponseDto>) {
super(partial);
Object.assign(this, partial);
Expand Down
10 changes: 0 additions & 10 deletions src/movie/dto/response/movie-docs.response.dto.ts

This file was deleted.

6 changes: 3 additions & 3 deletions src/movie/dto/response/possible-value.response.dto.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ApiProperty } from '@nestjs/swagger';
import { Expose } from 'class-transformer';
import { transliterate } from 'transliteration';
import { ApiNullableProperty } from '../../../common/decorators/api-nullable-property.decorator';

export class PossibleValueDto {
@ApiProperty({ description: 'Значение по которому нужно делать запрос в базу данных' })
@ApiNullableProperty({ description: 'Значение по которому нужно делать запрос в базу данных' })
@Expose()
name: string;

@ApiProperty({ description: 'Вспомогательное значение' })
@ApiNullableProperty({ description: 'Вспомогательное значение' })
@Expose()
slug: string;

Expand Down
4 changes: 0 additions & 4 deletions src/movie/dto/update-movie.dto.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/movie/dto/v1.3/movie.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class MovieDtoV1_3 extends MovieDtoV1 {
@ApiNullableProperty({ example: 20, description: 'Средняя продолжительность серии' })
seriesLength: number;

@ApiProperty({ example: true, description: 'Признак сериала' })
@ApiNullableProperty({ example: true, description: 'Признак сериала' })
isSeries: boolean;

@ApiNullableProperty({ isArray: true, type: () => Audience })
Expand Down
3 changes: 2 additions & 1 deletion src/movie/dto/v1.4/movie-find-one-params.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { IsNumberParam } from '../../../common/validation/is-number-param';
import { IsValueInRange } from '../../../common/validation/is-value-in-range';
import { ToArray } from '../../../common/decorators/transform/to-array.decorator';
import { ApiProperty } from '@nestjs/swagger';
import { ApiNullableProperty } from '../../../common/decorators/api-nullable-property.decorator';

export class MovieFindOneParamsDtoV1_4 {
@ApiProperty({ required: true, description: 'ID из кинопоиска' })
@ApiNullableProperty({ required: true, description: 'ID из кинопоиска' })
@IsOptional()
@ToArray()
@Validate(IsValueInRange, [250, 7000000])
Expand Down
20 changes: 10 additions & 10 deletions src/movie/dto/v1.4/movie.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ import { LinkedMovie, Logo, Rating } from '../../schemas/movie.schema';
import { ApiProperty, OmitType } from '@nestjs/swagger';

export class LinkedMovieV1_4 extends LinkedMovie {
@ApiProperty({ type: () => Rating })
@ApiNullableProperty({ type: () => Rating })
rating: Rating;

@ApiProperty({ type: () => Number, example: 2021 })
@ApiNullableProperty({ type: () => Number, example: 2021 })
year: number;
}

export class NetworkItemV1_4 {
@ApiProperty({ type: () => String, example: 'Netflix' })
@ApiNullableProperty({ type: () => String, example: 'Netflix' })
name: string;

@ApiProperty({ type: () => Logo })
@ApiNullableProperty({ type: () => Logo })
logo: Logo;
}
export class NetworksV1_4 {
@ApiProperty({ type: () => NetworkItemV1_4, isArray: true })
@ApiNullableProperty({ type: () => NetworkItemV1_4, isArray: true })
items: NetworkItemV1_4[];
}

Expand All @@ -30,18 +30,18 @@ export class MovieDtoV1_4 extends OmitType(MovieDtoV1_3, ['productionCompanies']
})
lists: string[];

@ApiProperty({ type: () => LinkedMovieV1_4, isArray: true })
@ApiNullableProperty({ type: () => LinkedMovieV1_4, isArray: true })
similarMovies: LinkedMovieV1_4[];

@ApiProperty({ type: () => LinkedMovieV1_4, isArray: true })
@ApiNullableProperty({ type: () => LinkedMovieV1_4, isArray: true })
sequelsAndPrequels: LinkedMovieV1_4[];

@ApiProperty({ type: () => NetworksV1_4, isArray: true })
@ApiNullableProperty({ type: () => NetworksV1_4, isArray: true })
networks: NetworksV1_4;

@ApiProperty()
@ApiNullableProperty()
updatedAt: Date;

@ApiProperty()
@ApiNullableProperty()
createdAt: Date;
}
Loading

0 comments on commit 81a3da5

Please sign in to comment.