diff --git a/Quickstart.md b/Quickstart.md index 30404ce..2a8dd90 100644 --- a/Quickstart.md +++ b/Quickstart.md @@ -1 +1,65 @@ -TODO \ No newline at end of file +# Getting Started + +Let's start from making a normal NestJS app. + +```ts +import { Controller, Get } from '@nestjs/common'; +import { AppService } from './app.service'; + +@Controller() +export class AppController { + constructor(private readonly appService: AppService) {} + + @Get() + getHello(): string { + return this.appService.getHello(); + } +} +``` + +**Important:** This decorator package is only accepting asynchronous function for now. + +So we should change things to use async. + +```ts +import { Controller, Get } from '@nestjs/common'; +import { AppService } from './app.service'; + +@Controller() +export class AppController { + constructor(private readonly appService: AppService) {} + + @Get() + async getHello(): Promise { + return await this.appService.getHello(); + } +} +``` + +This is the template you will get when you start with `nest new [name]`. + +Now install `nestlogged` package. + +```sh +npm install nestlogged +``` + +Or, + +```sh +yarn add nestlogged +``` + +# Add Logging + +In this package, logging decorator is separated by two kind. + +1. LoggedRoute is used for methods in Controllers, with method decorators like @Get, @Post, etc. + +2. LoggedFunction is used for methods in any other class methods, like service. + +So, we can add a LoggedRoute decorator in controller example above. + +```ts + +```