src/iam/user/user.controller.ts
user
Methods |
| getTuroWidePermissions | ||||
getTuroWidePermissions(request)
|
||||
Decorators :
@Get('getTuroWidePermissions')
|
||||
|
Defined in src/iam/user/user.controller.ts:30
|
||||
|
Parameters :
Returns :
any
|
| preferences | ||||
preferences(request)
|
||||
Decorators :
@Get('preferences')
|
||||
|
Defined in src/iam/user/user.controller.ts:40
|
||||
|
Function to get user preferences from userId
Parameters :
Returns :
Promise<UserPreference[]>
user preferences or throw error if not found |
| updatePreference | ||||||||||||||||
updatePreference(preferenceKey: UserPreferenceKeys, preferenceValue: PreferenceValue, request)
|
||||||||||||||||
Decorators :
@Post('preferences/:preferenceKey')
|
||||||||||||||||
|
Defined in src/iam/user/user.controller.ts:52
|
||||||||||||||||
|
Function to update user preferences
Parameters :
Returns :
any
updated preference object |
| user | ||||||||
user(userId: string)
|
||||||||
Decorators :
@Get(':userId')
|
||||||||
|
Defined in src/iam/user/user.controller.ts:70
|
||||||||
|
Function to get user details from userId
Parameters :
Returns :
Promise<User>
user detais or throw error if not found |
| users | ||||||
users(searchString: string)
|
||||||
Decorators :
@Get('search')
|
||||||
|
Defined in src/iam/user/user.controller.ts:25
|
||||||
|
Parameters :
Returns :
Promise<User[]>
|
import {
Body,
Controller,
Get,
Param,
Post,
Query,
Request,
} from "@nestjs/common";
import { ApiBearerAuth } from "@nestjs/swagger";
import { User } from "./entity/user.entity";
import { UserService } from "./user.service";
import {
UserPreference,
UserPreferenceKeys,
} from "./entity/user.preference.entity";
import { PreferenceValue } from "./user.preference.type";
@ApiBearerAuth("access-token") // this appends authorization header for swagger UI
@Controller("user")
export class UserController {
constructor(private readonly userService: UserService) {}
@Get("search")
users(@Query("searchString") searchString: string): Promise<User[]> {
return this.userService.users(searchString);
}
@Get("getTuroWidePermissions")
getTuroWidePermissions(@Request() request) {
return this.userService.getTuroWidePermissions(request.user);
}
/**
* Function to get user preferences from userId
* @param userId : this is expected to be email always
* @returns user preferences or throw error if not found
*/
@Get("preferences")
preferences(@Request() request): Promise<UserPreference[]> {
return this.userService.getUserPreferences(request.user.id);
}
/**
* Function to update user preferences
* @param preferenceKey : key of preference to be updated
* @param preferenceValue : value of preference to be updated
* @param request : request object
* @returns updated preference object
*/
@Post("preferences/:preferenceKey")
updatePreference(
@Param("preferenceKey") preferenceKey: UserPreferenceKeys,
@Body() preferenceValue: PreferenceValue,
@Request() request,
) {
return this.userService.updateUserPreference(
request.user.id,
preferenceKey,
preferenceValue,
);
}
/**
* Function to get user details from userId
* @param userId : this is expected to be email always
* @returns user detais or throw error if not found
*/
@Get(":userId")
user(@Param("userId") userId: string): Promise<User> {
return this.userService.getUserDetails(userId);
}
}