14 lines
418 B
TypeScript
14 lines
418 B
TypeScript
import { createParamDecorator, ExecutionContext } from '@nestjs/common';
|
|
import { Response } from 'express';
|
|
import { User } from 'src/objects/user/user.entity';
|
|
|
|
/**
|
|
* Get the user from the response.
|
|
*/
|
|
export const LoggedInUser = createParamDecorator(
|
|
(data: unknown, ctx: ExecutionContext) => {
|
|
const response = ctx.switchToHttp().getResponse() as Response;
|
|
return response.locals.user as User;
|
|
},
|
|
);
|