Merge branch 'core'

This commit is contained in:
Jeremy Yin 2019-06-17 23:25:56 +08:00
commit c9a4cf1988
2 changed files with 30 additions and 2 deletions

3
src/posts/post.dto.ts Normal file
View File

@ -0,0 +1,3 @@
export class CreatePostDto {
readonly title: string
}

View File

@ -1,4 +1,29 @@
import { Controller } from '@nestjs/common';
import { Controller, Get, Post, Req, Query, Headers, Param, Body } from '@nestjs/common';
import { CreatePostDto } from './post.dto';
@Controller('posts')
export class PostsController {}
export class PostsController {
@Get()
index(@Headers('authorization') headers, @Query() query) {
console.log(headers)
console.log(query)
return [
{
title: 'hello ~'
}
]
}
@Get(':id')
show(@Param() params) {
return {
title: `Post ${params.id}`
}
}
@Post()
store(@Body() post: CreatePostDto) {
console.log(post)
return post
}
}