soon530 / nestjs-study

來學一下nestjs吧!
0 stars 0 forks source link

Controllers #6

Open soon530 opened 2 years ago

soon530 commented 2 years ago

https://docs.nestjs.com/controllers

soon530 commented 2 years ago

新增一個route http://localhost:3000/cats

import { Controller, Get } from '@nestjs/common';

@Controller('cats')
export class CatsController {
    @Get()
    findAll(): string {
        return 'This action returns all cats';
    }
}

要加到這裡來,不然抓不到~

@Module({
  imports: [],
  controllers: [AppController, CatsController],
  providers: [AppService],
})
soon530 commented 2 years ago

官網難看,改看 #8

直接下指定快快的,架構也幫忙放好好的。

% nest generate controller todo
CREATE src/todo/todo.controller.spec.ts (478 bytes)
CREATE src/todo/todo.controller.ts (97 bytes)
UPDATE src/app.module.ts (322 bytes)