-
-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
2,015 additions
and
786 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -euo pipefail | ||
|
||
SCRIPT_DIR=$(dirname "$0") | ||
ROOT=$(cd "$SCRIPT_DIR/../" && pwd)/ | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface IBuyCreditDto { | ||
quantity?: number; | ||
} |
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { CreditController } from './credit.controller'; | ||
import { CreditService } from './credit.service'; | ||
|
||
describe('CreditController', () => { | ||
let controller: CreditController; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
controllers: [CreditController], | ||
providers: [CreditService], | ||
}).compile(); | ||
|
||
controller = module.get<CreditController>(CreditController); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(controller).toBeDefined(); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Body, Controller, Get, Post, Req, UseGuards } from '@nestjs/common'; | ||
import { CreditService } from './credit.service'; | ||
import { ApiTags } from '@nestjs/swagger'; | ||
import { JwtAuthGuard } from 'src/auth/guards/jwt-auth.guard'; | ||
import { Request } from 'express'; | ||
import { BuyDto } from './dto/buy.dto'; | ||
|
||
@Controller('credit') | ||
@ApiTags('Credits') | ||
@UseGuards(JwtAuthGuard) | ||
export class CreditController { | ||
constructor(private readonly creditService: CreditService) {} | ||
|
||
@Get() | ||
async getAvailableCredits(@Req() req: Request) { | ||
const userId = req?.user?.id ?? ''; | ||
return this.creditService.getAvailableCredits(userId); | ||
} | ||
|
||
@Post('buy') | ||
async buyCredits(@Req() req: Request, @Body() buyDto: BuyDto) { | ||
const userId = req?.user?.id ?? ''; | ||
return this.creditService.buyCredits(userId, buyDto.quantity); | ||
} | ||
} |
Oops, something went wrong.