Skip to content

Instantly share code, notes, and snippets.

@paztek
Created May 16, 2021 20:24
Show Gist options
  • Save paztek/b60b489a6fc0209339574b31c6c835eb to your computer and use it in GitHub Desktop.
Save paztek/b60b489a6fc0209339574b31c6c835eb to your computer and use it in GitHub Desktop.
nestjs-count-api-calls-example-1
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,
});
}
}
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