add content

This commit is contained in:
liuyi 2025-05-11 23:45:58 +08:00
parent 57c0318bda
commit 2e03eca42d
4 changed files with 36 additions and 1 deletions

View File

@ -2,9 +2,10 @@ import { Module } from '@nestjs/common';
import { AppController } from './app.controller'; import { AppController } from './app.controller';
import { AppService } from './app.service'; import { AppService } from './app.service';
import { ContentModule } from './modules/content/content.module';
@Module({ @Module({
imports: [], imports: [ContentModule],
controllers: [AppController], controllers: [AppController],
providers: [AppService], providers: [AppService],
}) })

View File

@ -0,0 +1,8 @@
import { Module } from '@nestjs/common';
import { PostController } from './controllers/post.controller';
@Module({
controllers: [PostController],
})
export class ContentModule {}

View File

@ -0,0 +1,20 @@
import { Controller, Get } from '@nestjs/common';
import { PostEntity } from '../types';
const posts: PostEntity[] = [
{ title: '第一篇文章标题', body: '第一篇文章内容' },
{ title: '第二篇文章标题', body: '第二篇文章内容' },
{ title: '第三篇文章标题', body: '第三篇文章内容' },
{ title: '第四篇文章标题', body: '第四篇文章内容' },
{ title: '第五篇文章标题', body: '第五篇文章内容' },
{ title: '第六篇文章标题', body: '第六篇文章内容' },
].map((v, id) => ({ ...v, id }));
@Controller('posts')
export class PostController {
@Get()
async index() {
return posts;
}
}

View File

@ -0,0 +1,6 @@
export interface PostEntity {
id: number;
title: string;
summary?: string;
body: string;
}