Created
May 16, 2021 20:24
-
-
Save paztek/b60b489a6fc0209339574b31c6c835eb to your computer and use it in GitHub Desktop.
nestjs-count-api-calls-example-1
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
import { Controller, Get, UseGuards } from '@nestjs/common'; | |
import { AuthGuard } from '../auth/auth.guard'; | |
@UseGuards(AuthGuard) | |
@Controller() | |
export class BusinessController { | |
/** | |
* This endpoint costs 1 credit per call | |
*/ | |
@Get('/foo') | |
foo(): Promise<any> { | |
return Promise.resolve({ | |
value: Math.random(), | |
}); | |
} | |
/** | |
* This endpoint costs 2 credits per call | |
*/ | |
@Get('/bar') | |
bar(): Promise<any> { | |
return Promise.resolve({ | |
value: Math.random(), | |
anotherValue: Math.random() + Math.PI, | |
}); | |
} | |
} |
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
import { Module } from '@nestjs/common'; | |
import { AuthModule } from '../auth/auth.module'; | |
import { BusinessController } from './business.controller'; | |
@Module({ | |
imports: [AuthModule], | |
controllers: [BusinessController], | |
}) | |
export class BusinessModule {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment