forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcurrency.controller.ts
More file actions
37 lines (32 loc) · 1.15 KB
/
Copy pathcurrency.controller.ts
File metadata and controls
37 lines (32 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { Controller, Get, Post, Put, Body, Req, Query, UseGuards } from '@nestjs/common';
import { CurrencyService } from './currency.service';
import { ConversionService } from './conversion.service';
import { UpdatePreferenceDto } from './dto/update-preference.dto';
import { ConvertDto } from './dto/convert.dto';
@Controller('currency')
export class CurrencyController {
constructor(
private currencyService: CurrencyService,
private conversionService: ConversionService,
) { }
@Get('preferences')
async getPreferences(@Req() req: any) {
const userId = req.user.id;
return this.currencyService.getPreferences(userId);
}
@Put('preferences')
async updatePreferences(@Req() req: any, @Body() dto: UpdatePreferenceDto) {
const userId = req.user.id;
return this.currencyService.updatePreferences(userId, dto);
}
@Get('convert')
async convert(@Query() dto: ConvertDto) {
return this.conversionService.convert(dto.amount, dto.from, dto.to);
}
@Post('setup')
async firstLoginSetup(@Req() req: any) {
const userId = req.user.id;
const ip = req.ip;
return this.currencyService.firstLoginSetup(userId, ip);
}
}