Skip to content

Commit

Permalink
Big update
Browse files Browse the repository at this point in the history
  • Loading branch information
Kolobok12309 committed Apr 5, 2024
1 parent 0bc6449 commit 25384f0
Show file tree
Hide file tree
Showing 55 changed files with 2,050 additions and 890 deletions.
20 changes: 20 additions & 0 deletions apps/back/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,23 @@ Nest is an MIT-licensed open source project. It can grow thanks to the sponsors
## License

Nest is [MIT licensed](LICENSE).

## Migrations

### Create

```bash
pnpm migration:create ./migrations/SomeName
pnpm migration:generate ./migrations/SomeName
pnpm seed:create ./seeds/SomeName
```

### Run/Revert

```bash
pnpm migration:run
pnpm migration:revert

pnpm seed:run
pnpm seed:revert
```
23 changes: 11 additions & 12 deletions apps/back/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json",
"typeorm": "ts-node -r tsconfig-paths/register ../../node_modules/typeorm/cli.js",
"migration:generate": "pnpm typeorm migration:generate -n",
"migration:create": "pnpm typeorm migration:create -n",
"migration:run": "pnpm typeorm migration:run",
"migration:revert": "pnpm typeorm migration:revert",
"seed:generate": "pnpm typeorm migration:generate -c seed -n ",
"seed:create": "pnpm typeorm migration:create -c seed -n",
"seed:run": "pnpm typeorm migration:run -c seed",
"seed:revert": "pnpm typeorm migration:revert -c seed",
"migrations:run": "pnpm migration:run && yarn run seed:run",
"migrations:prod": "cross-env NODE_ENV=production yarn run typeorm migration:run && yarn run typeorm migration:run -c seed"
"typeorm": "ts-node -r tsconfig-paths/register --project tsconfig.json ./node_modules/typeorm/cli.js",
"migration:generate": "pnpm typeorm migration:generate -d ./typeorm/data-source.ts",
"migration:create": "pnpm typeorm migration:create",
"migration:run": "pnpm typeorm migration:run -d ./typeorm/data-source.ts",
"migration:revert": "pnpm typeorm migration:revert -d ./typeorm/data-source.ts",
"seed:create": "pnpm typeorm migration:create",
"seed:run": "pnpm typeorm migration:run -d ./typeorm/seed-data-source.ts",
"seed:revert": "pnpm typeorm migration:revert -d ./typeorm/seed-data-source.ts",
"migrations:run": "pnpm migration:run && pnpm seed:run",
"migrations:prod": "cross-env NODE_ENV=production pnpm typeorm migration:run && pnpm typeorm migration:run -d ./typeorm/seed-data-source.ts"
},
"engines": {
"node": "18.x",
Expand Down Expand Up @@ -79,7 +78,7 @@
"swagger-ui-express": "^5.0.0",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typeorm": "^0.3.19",
"typeorm": "^0.3.20",
"typescript": "^5.3.3"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion apps/back/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ConfigModule } from '@nestjs/config';

import { UsersModule } from './users';
import { DbModule } from './db';
import { StorageModule } from './storage';
import { StorageModule } from './files';
import { ClientsModule } from './clients';

@Module({
Expand Down
9 changes: 2 additions & 7 deletions apps/back/src/clients/clients.module.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { Module } from '@nestjs/common';

import {
BreedModule,
BreedGroupModule,
DogModule,
PersonModule,
} from './cruds';
import { BreedModule, BreedGroupModule, DogModule } from './cruds';

@Module({
imports: [BreedModule, BreedGroupModule, DogModule, PersonModule],
imports: [BreedModule, BreedGroupModule, DogModule],
})
export class ClientsModule {}
16 changes: 1 addition & 15 deletions apps/back/src/clients/cruds/dog/dog.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ import {
import { Dog, Sex } from '@hb/types';

import { UserEntity } from '@/users';
import { FileEntity } from '@/storage';
import { FileEntity } from '@/files';

import { PersonEntity } from '../person';
import { BreedEntity } from '../breed';

@Entity('dogs', {
Expand Down Expand Up @@ -87,13 +86,6 @@ export class DogEntity implements Omit<Dog, 'titles' | 'class' | 'shows'> {
@JoinColumn()
avatar: FileEntity;

@ManyToOne(() => PersonEntity, {
onDelete: 'SET NULL',
nullable: true,
eager: true,
})
breeder: PersonEntity;

// TODO Mb replace it to OneToMany and update FileEntity
// Not OneToMany, because typeorm not support
// id's array in entity
Expand All @@ -103,12 +95,6 @@ export class DogEntity implements Omit<Dog, 'titles' | 'class' | 'shows'> {
@JoinTable()
files: FileEntity[];

@ManyToOne(() => PersonEntity, {
onDelete: 'CASCADE',
eager: true,
})
owner: PersonEntity;

@ManyToOne(() => UserEntity, {
onDelete: 'CASCADE',
})
Expand Down
10 changes: 1 addition & 9 deletions apps/back/src/clients/cruds/dog/dto/dog.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import {

import { Dog, Sex } from '@hb/types';

import type { FileDto } from '@/storage/dto';

import type { PersonDto } from '../../person/dto';
import type { FileDto } from '@/files/dto';

const { CREATE, UPDATE } = CrudValidationGroups;

Expand Down Expand Up @@ -116,12 +114,6 @@ export class DogDto implements Omit<Dog, 'titles' | 'class' | 'shows'> {
@ApiProperty()
avatar?: FileDto;

@ApiProperty()
breeder?: PersonDto;

@ApiProperty()
files?: FileDto[];

@ApiProperty()
owner?: PersonDto;
}
2 changes: 0 additions & 2 deletions apps/back/src/clients/cruds/dog/dto/edit-dog.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { DogDto } from './dog.dto';

export class EditDogDto extends OmitType(DogDto, [
'id',
'owner',
'breeder',
'avatar',
'files',
'handlerId',
Expand Down
1 change: 0 additions & 1 deletion apps/back/src/clients/cruds/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './breed';
export * from './breed-group';
export * from './dog';
export * from './person';
15 changes: 0 additions & 15 deletions apps/back/src/clients/cruds/person/dto/edit-person.dto.ts

This file was deleted.

2 changes: 0 additions & 2 deletions apps/back/src/clients/cruds/person/dto/index.ts

This file was deleted.

60 changes: 0 additions & 60 deletions apps/back/src/clients/cruds/person/dto/person.dto.ts

This file was deleted.

3 changes: 0 additions & 3 deletions apps/back/src/clients/cruds/person/index.ts

This file was deleted.

75 changes: 0 additions & 75 deletions apps/back/src/clients/cruds/person/person.controller.ts

This file was deleted.

73 changes: 0 additions & 73 deletions apps/back/src/clients/cruds/person/person.entity.ts

This file was deleted.

Loading

0 comments on commit 25384f0

Please sign in to comment.