app.controller.ts
nest.js/02-intermediate/code/app.controller.ts
import { Controller, Get, UseGuards } from '@nestjs/common';
import { AppService } from './app.service';
import { AuthGuard } from './auth/guards/auth.guard';
import { Public } from './auth/decorators/public.decorator';
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@Public()
@Get()
getHello(): string {
return this.appService.getHello();
}
@Public()
@Get('health')
getHealth() {
return {
status: 'ok',
message: 'Server is running',
timestamp: new Date().toISOString(),
};
}
@UseGuards(AuthGuard)
@Get('protected')
getProtected() {
return {
message: 'This is a protected route',
timestamp: new Date().toISOString(),
};
}
}
관련 글
app.controller.ts
app.controller.ts — typescript source code from the nest.js learning materials (nest.js/01-beginner/code/app.controller.ts).
글 읽기 →app.module.ts
app.module.ts — typescript source code from the nest.js learning materials (nest.js/01-beginner/code/app.module.ts).
글 읽기 →app.service.ts
app.service.ts — typescript source code from the nest.js learning materials (nest.js/01-beginner/code/app.service.ts).
글 읽기 →main.ts
main.ts — typescript source code from the nest.js learning materials (nest.js/01-beginner/code/main.ts).
글 읽기 →todos.controller.ts
todos.controller.ts — typescript source code from the nest.js learning materials (nest.js/01-beginner/code/todos/todos.controller.ts).
글 읽기 →todos.module.ts
todos.module.ts — typescript source code from the nest.js learning materials (nest.js/01-beginner/code/todos/todos.module.ts).
글 읽기 →