19 lines
619 B
TypeScript
19 lines
619 B
TypeScript
import { Controller, Get } from '@nestjs/common';
|
|
import { ApiTags, ApiOperation } from '@nestjs/swagger';
|
|
import { Public } from '../../common/decorators/public.decorator';
|
|
import { BlogService } from './blog.service';
|
|
import { PublicBlogList } from './dto/blog.dto';
|
|
|
|
@ApiTags('blog')
|
|
@Controller('api/v1/blog')
|
|
export class BlogController {
|
|
constructor(private readonly blog: BlogService) {}
|
|
|
|
@Public()
|
|
@Get('posts')
|
|
@ApiOperation({ summary: 'Public list of published blog posts' })
|
|
async listPosts(): Promise<PublicBlogList> {
|
|
const posts = await this.blog.listPublished();
|
|
return { posts };
|
|
}
|
|
} |