fix: add page slug validate

This commit is contained in:
Innei
2022-04-15 11:31:27 +08:00
parent 24da092644
commit deef8098ea

View File

@@ -9,6 +9,7 @@ import {
Post,
Put,
Query,
UnprocessableEntityException,
} from '@nestjs/common'
import { Auth } from '~/common/decorator/auth.decorator'
@@ -55,6 +56,9 @@ export class PageController {
@Get('/slug/:slug')
async getPageBySlug(@Param('slug') slug: string) {
if (typeof slug !== 'string') {
throw new UnprocessableEntityException('slug must be string')
}
const page = await this.pageService.model
.findOne({
slug,