Files
Montech_Landing/apps/api/src/seo/seo.controller.ts
T

35 lines
957 B
TypeScript
Raw Normal View History

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);
}
}