-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathuser-preferences.controller.ts
More file actions
30 lines (26 loc) · 1.06 KB
/
user-preferences.controller.ts
File metadata and controls
30 lines (26 loc) · 1.06 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
import { Body, Controller, Get, Patch } from '@nestjs/common';
import { ApiOkResponse, ApiTags } from '@nestjs/swagger';
import { UserPreferencesService } from './user-preferences.service';
import { UpdateUserPreferencesDto, UserPreferencesResponseDto } from './user-preferences.dto';
import { CurrentAuth } from '../auth/auth-context.decorator';
import type { AuthContext } from '../auth/types';
@ApiTags('user-preferences')
@Controller('users/me/preferences')
export class UserPreferencesController {
constructor(private readonly service: UserPreferencesService) {}
@Get()
@ApiOkResponse({ type: UserPreferencesResponseDto })
async getPreferences(
@CurrentAuth() auth: AuthContext | null,
): Promise<UserPreferencesResponseDto> {
return this.service.getPreferences(auth);
}
@Patch()
@ApiOkResponse({ type: UserPreferencesResponseDto })
async updatePreferences(
@CurrentAuth() auth: AuthContext | null,
@Body() body: UpdateUserPreferencesDto,
): Promise<UserPreferencesResponseDto> {
return this.service.updatePreferences(auth, body);
}
}