Skip to content

Commit

Permalink
fix: try debug fn error
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <[email protected]>
  • Loading branch information
Innei committed Sep 3, 2024
1 parent 2b477ba commit df9a164
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
11 changes: 7 additions & 4 deletions apps/core/src/modules/serverless/serverless.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,17 @@ export class ServerlessController {
getters: true,
})

const notExistMessage = 'serverless function is not exist or not enabled'

const errorPath = `Path: /${reference}/${name}`
if (!snippet) {
throw new NotFoundException(notExistMessage)
throw new NotFoundException(
`serverless function is not exist, ${errorPath}`,
)
}

if (!snippet.enable) {
throw new NotFoundException(notExistMessage)
throw new BadRequestException(
`serverless function is not enabled, ${errorPath}`,
)
}

if (snippet.private && !isAuthenticated) {
Expand Down
3 changes: 2 additions & 1 deletion apps/core/src/modules/snippet/snippet.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
NotFoundException,
} from '@nestjs/common'

import { RequestContext } from '~/common/contexts/request.context'
import { EventScope } from '~/constants/business-event.constant'
import { RedisKeys } from '~/constants/cache.constant'
import { EventBusEvents } from '~/constants/event-bus.constant'
Expand Down Expand Up @@ -263,7 +264,7 @@ export class SnippetService {
throw new NotFoundException()
}

if (snippet.private) {
if (snippet.private && !RequestContext.currentIsAuthenticated()) {
throw new ForbiddenException('snippet is private')
}

Expand Down

0 comments on commit df9a164

Please sign in to comment.