-
-
Notifications
You must be signed in to change notification settings - Fork 663
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(server): fix dto validation method, fix cors config (#446)
Signed-off-by: maslow <wangfugen@126.com> Signed-off-by: maslow <wangfugen@126.com>
- Loading branch information
Showing
14 changed files
with
25,087 additions
and
75 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,40 +1,34 @@ | ||
import { ApiProperty } from '@nestjs/swagger' | ||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger' | ||
import { IsEnum, IsNotEmpty, Length } from 'class-validator' | ||
import { ApplicationState } from '../entities/application.entity' | ||
|
||
export class CreateApplicationDto { | ||
@ApiProperty({ required: true }) | ||
@Length(1, 64) | ||
@IsNotEmpty() | ||
displayName: string | ||
|
||
@ApiProperty({ | ||
@ApiPropertyOptional({ | ||
default: ApplicationState.ApplicationStateRunning, | ||
required: false, | ||
enum: ApplicationState, | ||
}) | ||
@IsNotEmpty() | ||
@IsEnum(ApplicationState) | ||
state: ApplicationState | ||
|
||
@ApiProperty() | ||
@IsNotEmpty() | ||
region: string | ||
|
||
@ApiProperty() | ||
@IsNotEmpty() | ||
bundleName: string | ||
|
||
@ApiProperty() | ||
@IsNotEmpty() | ||
runtimeName: string | ||
|
||
static validate(dto: CreateApplicationDto): string | null { | ||
if (!dto.displayName) { | ||
return 'name is required' | ||
} | ||
if (!dto.state) { | ||
return 'state is required' | ||
} | ||
if (!dto.region) { | ||
return 'region is required' | ||
} | ||
if (!dto.bundleName) { | ||
return 'bundleName is required' | ||
} | ||
|
||
validate(): string | null { | ||
return null | ||
} | ||
} |
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
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,26 +1,30 @@ | ||
import { ApiProperty } from '@nestjs/swagger' | ||
import { IsEnum, IsNotEmpty, IsString, Length } from 'class-validator' | ||
import { BucketPolicy } from '../entities/bucket.entity' | ||
|
||
export class CreateBucketDto { | ||
@ApiProperty({ | ||
description: 'The short name of the bucket which not contain the appid', | ||
}) | ||
@IsNotEmpty() | ||
@Length(3, 32) | ||
shortName: string | ||
|
||
@ApiProperty() | ||
appid: string | ||
|
||
@ApiProperty({ | ||
enum: BucketPolicy, | ||
}) | ||
@IsEnum(BucketPolicy) | ||
@IsNotEmpty() | ||
policy: BucketPolicy | ||
|
||
@ApiProperty({ | ||
description: 'The storage capacity of the bucket: "1Gi", "0.5Gi", "100Gi"', | ||
}) | ||
@IsNotEmpty() | ||
@IsString() | ||
storage: string | ||
|
||
get name() { | ||
return `${this.appid}-${this.shortName}` | ||
fullname(appid: string) { | ||
return `${appid}-${this.shortName}` | ||
} | ||
} |
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,13 @@ | ||
import { ApiProperty } from '@nestjs/swagger' | ||
import { IsNotEmpty, Length } from 'class-validator' | ||
|
||
export class CreateCollectionDto { | ||
@ApiProperty() | ||
@IsNotEmpty() | ||
@Length(3, 32) | ||
name: string | ||
|
||
async validate() { | ||
if (!this.name) { | ||
return 'Collection name is required' | ||
} | ||
|
||
return null | ||
} | ||
} |
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
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