-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve DTOs with helpers, and other clean up (#137)
- Loading branch information
1 parent
fc08972
commit 7656338
Showing
16 changed files
with
2,240 additions
and
36,661 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,23 @@ | ||
import { PartialType } from '@nestjs/mapped-types'; | ||
import { Asset } from '../entities/asset.entity'; | ||
import { User } from 'src/users/entities/user.entity'; | ||
import { IsNotEmpty, IsEnum, IsOptional } from 'class-validator'; | ||
|
||
import { User } from '../../users/entities/user.entity'; | ||
import { AssetType, Condition } from '../constants'; | ||
|
||
export class CreateAssetDto extends PartialType(Asset) { | ||
export class CreateAssetDto { | ||
@IsNotEmpty() | ||
title: string; | ||
|
||
@IsNotEmpty() | ||
description: string; | ||
poster_id: User; | ||
|
||
@IsNotEmpty() | ||
poster: User; | ||
|
||
@IsOptional() | ||
@IsEnum(AssetType) | ||
type: AssetType; | ||
|
||
@IsOptional() | ||
@IsEnum(Condition) | ||
condition: Condition; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { PartialType } from '@nestjs/mapped-types'; | ||
|
||
import { CreateAssetDto } from './create-asset.dto'; | ||
|
||
//look at nest docs | ||
export class UpdateAssetDto extends PartialType(CreateAssetDto) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
server/src/categories/dto/create-category.ts → ...src/categories/dto/create-category.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
import { IsNotEmpty, IsOptional } from 'class-validator'; | ||
|
||
export class CreateCategoryDto { | ||
@IsNotEmpty() | ||
name: string; | ||
|
||
@IsOptional() | ||
applies_to_assets: boolean; | ||
|
||
@IsOptional() | ||
applies_to_organizations: boolean; | ||
} |
2 changes: 1 addition & 1 deletion
2
server/src/categories/dto/update-category.ts → ...src/categories/dto/update-category.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { PartialType } from '@nestjs/mapped-types'; | ||
import { CreateCategoryDto } from './create-category'; | ||
import { CreateCategoryDto } from './create-category.dto'; | ||
|
||
export class UpdateCategoryDto extends PartialType(CreateCategoryDto) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
import { PartialType } from '@nestjs/mapped-types'; | ||
import { User } from 'src/users/entities/user.entity'; | ||
import { Message } from '../entities/message.entity'; | ||
import { IsNotEmpty, IsEnum, IsOptional } from 'class-validator'; | ||
|
||
export class CreateMessageDto extends PartialType(Message) { | ||
import { User } from '../../users/entities/user.entity'; | ||
import { Transaction } from '../../transactions/entities/transaction.entity'; | ||
|
||
export class CreateMessageDto { | ||
@IsNotEmpty() | ||
text: string; | ||
|
||
@IsNotEmpty() | ||
user: User; | ||
transaction_id: number; // remove once Transaction is set up and a relationship is used in the entity | ||
|
||
@IsNotEmpty() | ||
transaction: Transaction; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,30 @@ | ||
import { Organization } from '../entities/organization.entity'; | ||
import { PartialType } from '@nestjs/mapped-types'; | ||
import { IsNotEmpty } from 'class-validator'; | ||
|
||
export class CreateOrganizationDto { | ||
@IsNotEmpty() | ||
name: string; | ||
|
||
@IsNotEmpty() | ||
description: string; | ||
|
||
@IsNotEmpty() | ||
website: string; | ||
|
||
@IsNotEmpty() | ||
address: string; | ||
|
||
@IsNotEmpty() | ||
phone: string; | ||
|
||
@IsNotEmpty() | ||
city: string; | ||
|
||
@IsNotEmpty() | ||
state: string; | ||
|
||
@IsNotEmpty() | ||
ein: number; | ||
|
||
@IsNotEmpty() | ||
tax_exempt_id: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,5 +37,5 @@ export class UserOrganization { | |
user!: User; | ||
|
||
@CreateDateColumn() | ||
created_at: Date; | ||
created_date: Date; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
import { PartialType } from '@nestjs/mapped-types'; | ||
import { User } from '../entities/user.entity'; | ||
import { IsEmail, IsNotEmpty } from 'class-validator'; | ||
|
||
export class CreateUserDto extends PartialType(User) { | ||
export class CreateUserDto { | ||
@IsNotEmpty() | ||
first_name: string; | ||
|
||
@IsNotEmpty() | ||
last_name: string; | ||
|
||
@IsNotEmpty() | ||
@IsEmail() | ||
email: string; | ||
|
||
@IsNotEmpty() | ||
password: string; | ||
} |