fix: project vaildation
This commit is contained in:
@@ -11,6 +11,7 @@ import { RedisIoAdapter } from './common/adapters/socket.adapter'
|
||||
import { SpiderGuard } from './common/guard/spider.guard'
|
||||
import { LoggingInterceptor } from './common/interceptors/logging.interceptor'
|
||||
import { MyLogger } from './processors/logger/logger.service'
|
||||
import { isTest } from './utils'
|
||||
const Origin = Array.isArray(CROSS_DOMAIN.allowedOrigins)
|
||||
? CROSS_DOMAIN.allowedOrigins
|
||||
: false
|
||||
@@ -59,7 +60,7 @@ async function bootstrap() {
|
||||
}),
|
||||
)
|
||||
app.useGlobalGuards(new SpiderGuard())
|
||||
app.useWebSocketAdapter(new RedisIoAdapter(app))
|
||||
!isTest && app.useWebSocketAdapter(new RedisIoAdapter(app))
|
||||
|
||||
if (isDev) {
|
||||
const { DocumentBuilder, SwaggerModule } = await import('@nestjs/swagger')
|
||||
|
||||
@@ -34,7 +34,9 @@ export class ProjectModel extends BaseModel {
|
||||
})
|
||||
@IsUrl({ require_protocol: true }, { message: '请更正为正确的网址' })
|
||||
@IsOptional()
|
||||
@Transform(({ value }) => (value.length ? value : null))
|
||||
@Transform(({ value }) =>
|
||||
typeof value === 'string' && value.length ? value : null,
|
||||
)
|
||||
previewUrl?: string
|
||||
|
||||
@prop({
|
||||
@@ -42,7 +44,9 @@ export class ProjectModel extends BaseModel {
|
||||
})
|
||||
@IsOptional()
|
||||
@IsUrl({ require_protocol: true }, { message: '请更正为正确的网址' })
|
||||
@Transform(({ value }) => (value.length ? value : null))
|
||||
@Transform(({ value }) =>
|
||||
typeof value === 'string' && value.length ? value : null,
|
||||
)
|
||||
docUrl?: string
|
||||
|
||||
@prop({
|
||||
@@ -50,7 +54,9 @@ export class ProjectModel extends BaseModel {
|
||||
})
|
||||
@IsOptional()
|
||||
@IsUrl({ require_protocol: true }, { message: '请更正为正确的网址' })
|
||||
@Transform(({ value }) => (value.length ? value : null))
|
||||
@Transform(({ value }) =>
|
||||
typeof value === 'string' && value.length ? value : null,
|
||||
)
|
||||
projectUrl?: string
|
||||
|
||||
@IsUrl({ require_protocol: true }, { each: true })
|
||||
@@ -69,7 +75,9 @@ export class ProjectModel extends BaseModel {
|
||||
validate: validateURL,
|
||||
})
|
||||
@IsUrl({ require_protocol: true }, { message: '请更正为正确的网址' })
|
||||
@Transform(({ value }) => (value.length ? value : null))
|
||||
@Transform(({ value }) =>
|
||||
typeof value === 'string' && value.length ? value : null,
|
||||
)
|
||||
@IsOptional()
|
||||
avatar?: string
|
||||
|
||||
|
||||
Reference in New Issue
Block a user