fix: set select false for secret

Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
Innei
2022-11-26 20:08:45 +08:00
parent f1fe50e161
commit 7beeab3e15
3 changed files with 4 additions and 3 deletions

View File

@@ -77,6 +77,7 @@ export class ServerlessController {
type: SnippetType.Function,
method: requestMethod,
})
.select('+secret')
.lean()
const notExistMessage = 'serverless function is not exist or not enabled'

View File

@@ -92,7 +92,7 @@ export class SnippetModel extends BaseModel {
@IsOptional()
method?: string
@prop()
@prop({ select: false })
@IsString()
@IsOptional()
@Transform(({ value }) => (isNil(value) ? value : stringify(value)))

View File

@@ -56,7 +56,7 @@ export class SnippetService {
async update(id: string, newModel: SnippetModel) {
await this.validateTypeAndCleanup(newModel)
delete newModel.created
const old = await this.model.findById(id).lean()
const old = await this.model.findById(id).select('+secret').lean()
if (!old) {
throw new NotFoundException()
@@ -172,7 +172,7 @@ export class SnippetService {
}
async getSnippetById(id: string) {
const doc = await this.model.findById(id).lean()
const doc = await this.model.findById(id).select('+secret').lean()
if (!doc) {
throw new NotFoundException()
}