generated from nestjs/typescript-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
19ef35f
commit 77cf957
Showing
12 changed files
with
236 additions
and
50 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,51 @@ | ||
/* eslint-disable prettier/prettier */ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
import { Controller, Get, Post, Patch, Delete, Param, Body } from '@nestjs/common'; | ||
import { | ||
Controller, | ||
Get, | ||
Post, | ||
Patch, | ||
Delete, | ||
Param, | ||
Body, | ||
} from '@nestjs/common'; | ||
import { CatsService } from './cat.service'; | ||
import { Cat } from './cat.schema'; | ||
import { CreateCatDto } from './dto/create-cat.dto'; | ||
import { UpdatecatDto } from './dto/update-cat.dto'; | ||
import { ApiBody, ApiCreatedResponse, ApiOkResponse } from '@nestjs/swagger'; | ||
import { ApiTags} from '@nestjs/swagger'; | ||
|
||
@ApiTags('Cat') | ||
@Controller('Cat') | ||
export class CatController { | ||
constructor(private readonly catsService: CatsService) {} | ||
|
||
@Post() | ||
async create(@Body() createCatDto: CreateCatDto){ | ||
@Post('cat') | ||
@ApiCreatedResponse({ description: 'Cats add' }) | ||
@ApiBody({ type: CreateCatDto }) | ||
async create(@Body() createCatDto: CreateCatDto) { | ||
return this.catsService.create(createCatDto); | ||
} | ||
|
||
@Get() | ||
@Get('cat') | ||
async findAll(): Promise<Cat[]> { | ||
return this.catsService.findAll(); | ||
} | ||
|
||
@Patch(':id') | ||
async update( | ||
@Param('id') id: string, | ||
@Body() UpdatecatDto: UpdatecatDto, | ||
) { | ||
@Get('cat/:id') | ||
async fineOne(@Param ('id') id: string): Promise<Cat> { | ||
return this.catsService.findOne(id); | ||
} | ||
|
||
@Patch('cat/:id') | ||
@ApiOkResponse({ description: 'Add new cats' }) | ||
async update(@Param('id') id: string, @Body() UpdatecatDto: UpdatecatDto) { | ||
return this.catsService.update(id, UpdatecatDto); | ||
} | ||
@Delete(':id') | ||
|
||
@Delete('cat/:id') | ||
async remove(@Param('id') id: string) { | ||
return this.catsService.delete(id); | ||
|
||
return this.catsService.delete(id); | ||
} | ||
|
||
|
||
}; | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,37 @@ | ||
/* eslint-disable prettier/prettier */ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsString } from 'class-validator' | ||
|
||
export class CreateCatDto { | ||
@ApiProperty({ type: String, description: 'name' }) | ||
@IsString() | ||
name: string; | ||
|
||
@ApiProperty({ type: String, description: 'age' }) | ||
@IsString() | ||
age: string; | ||
|
||
@ApiProperty({ type: String, description: 'breed' }) | ||
@IsString() | ||
breed: string; | ||
|
||
@ApiProperty({ type : String, description : 'Gender'}) | ||
@IsString() | ||
Gender: string; | ||
|
||
@ApiProperty({ type : String, description : 'Vaccine'}) | ||
@IsString() | ||
vaccine: string; | ||
|
||
@ApiProperty({ type : String, description : 'history'}) | ||
@IsString() | ||
history: string; | ||
|
||
@ApiProperty({ type : String, description : 'Country'}) | ||
@IsString() | ||
country: string; | ||
|
||
@ApiProperty({ type : String, description : 'Farm'}) | ||
@IsString() | ||
farm: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
/* eslint-disable prettier/prettier */ | ||
import { ApiProperty } from '@nestjs/swagger'; | ||
import { IsString } from 'class-validator'; | ||
|
||
export class UpdatecatDto { | ||
readonly name: string; | ||
readonly age: string; | ||
|
||
} | ||
|
||
@ApiProperty({ type: String, description: 'Vaccine' }) | ||
@IsString() | ||
vaccine: string; | ||
|
||
@ApiProperty({ type: String, description: 'history' }) | ||
@IsString() | ||
history: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
/* eslint-disable prettier/prettier */ | ||
import { NestFactory } from '@nestjs/core'; | ||
import { AppModule } from './app.module'; | ||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; | ||
|
||
async function bootstrap() { | ||
const app = await NestFactory.create(AppModule); | ||
await app.listen(3006); | ||
const config = new DocumentBuilder() | ||
.setTitle('Backend API') | ||
.setVersion('1.0') | ||
.build(); | ||
const document = SwaggerModule.createDocument(app, config); | ||
SwaggerModule.setup('api', app, document); | ||
|
||
await app.listen(3007); | ||
} | ||
bootstrap(); |
Oops, something went wrong.