Scaffold SSR site with CMS/blog/gallery/SEO admin and deploy configs for montech.ir. Co-authored-by: Cursor <cursoragent@cursor.com>
35 lines
957 B
TypeScript
35 lines
957 B
TypeScript
import { Body, Controller, Get, Param, Put, UseGuards } from "@nestjs/common";
|
|
import { IsBoolean, IsOptional, IsString } from "class-validator";
|
|
import { SeoService } from "./seo.service";
|
|
import { JwtAuthGuard } from "../auth/jwt-auth.guard";
|
|
|
|
class SeoDto {
|
|
@IsOptional() @IsString() title?: string;
|
|
@IsOptional() @IsString() description?: string;
|
|
@IsOptional() @IsString() ogImage?: string;
|
|
@IsOptional() @IsString() canonical?: string;
|
|
@IsOptional() @IsBoolean() noIndex?: boolean;
|
|
}
|
|
|
|
@Controller()
|
|
export class SeoController {
|
|
constructor(private seo: SeoService) {}
|
|
|
|
@Get("public/pages/:key")
|
|
getPublic(@Param("key") key: string) {
|
|
return this.seo.getByKey(key);
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Get("admin/pages")
|
|
list() {
|
|
return this.seo.listPages();
|
|
}
|
|
|
|
@UseGuards(JwtAuthGuard)
|
|
@Put("admin/pages/:key/seo")
|
|
update(@Param("key") key: string, @Body() dto: SeoDto) {
|
|
return this.seo.updateSeo(key, dto);
|
|
}
|
|
}
|