Skip to content

Commit

Permalink
controller_test
Browse files Browse the repository at this point in the history
  • Loading branch information
bodyduardU committed Mar 8, 2023
1 parent 966b021 commit 394123d
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
3 changes: 2 additions & 1 deletion nestjs/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { CatsController } from './cats/cats.controller';

@Module({
imports: [],
controllers: [AppController],
controllers: [AppController, CatsController],
providers: [AppService],
})
export class AppModule {}
18 changes: 18 additions & 0 deletions nestjs/src/cats/cats.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { CatsController } from './cats.controller';

describe('CatsController', () => {
let controller: CatsController;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [CatsController],
}).compile();

controller = module.get<CatsController>(CatsController);
});

it('should be defined', () => {
expect(controller).toBeDefined();
});
});
35 changes: 35 additions & 0 deletions nestjs/src/cats/cats.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Controller, Get, Req, Res, Post, HttpStatus } from '@nestjs/common';
import { HttpCode, Param } from '@nestjs/common/decorators';
// import { Request } from '@nestjs/common/decorators';
import { Request } from 'express';
@Controller('cats')
export class CatsController {
@Post()
create(): string {
return 'This action asd';
}

@Get()
findAll(@Res({ passthrough: true }) res: Response) {
// res.status(HttpStatus.OK);
return ['123'];
}

@Get(':id')
findOne(@Param('id') id: string): string {
return `this is ${id}`;
}
// @Get(':id')
// findOne(@Param() params): string {
// console.log(params.id);
// return `123 ${params.id}`;
// }
// @Get('')
// findAll(@Req() request: Request): string {
// return 'asdasd';
// }
// @Get()
// find(): string {
// return 'ok';
// }
}

0 comments on commit 394123d

Please sign in to comment.