forked from ZyntariHQ/Invoisio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusers.controller.ts
More file actions
47 lines (42 loc) · 1.11 KB
/
Copy pathusers.controller.ts
File metadata and controls
47 lines (42 loc) · 1.11 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
38
39
40
41
42
43
44
45
46
47
import {
Body,
Controller,
Delete,
Get,
Patch,
Post,
Req,
UseGuards,
} from "@nestjs/common";
import { UsersService } from "./users.service";
import { AuthGuard } from "@nestjs/passport";
import { ApiBearerAuth, ApiTags } from "@nestjs/swagger";
@ApiTags("users")
@Controller("users")
@UseGuards(AuthGuard("jwt"))
@ApiBearerAuth()
export class UsersController {
constructor(private readonly usersService: UsersService) {}
@Post("push-token")
async addPushToken(@Req() req, @Body("token") token: string) {
return this.usersService.addPushToken(req.user.id, token);
}
@Delete("push-token")
async removePushToken(@Req() req, @Body("token") token: string) {
return this.usersService.removePushToken(req.user.id, token);
}
@Patch("preferences")
async updatePreferences(
@Req() req,
@Body("pushNotificationsEnabled") pushNotificationsEnabled: boolean,
) {
return this.usersService.updatePreferences(
req.user.id,
pushNotificationsEnabled,
);
}
@Get("preferences")
async getPreferences(@Req() req) {
return this.usersService.getPreferences(req.user.id);
}
}