forked from Yara724/api
Initial commit after migration to gitea
This commit is contained in:
9
src/decorators/clientKey.decorator.ts
Normal file
9
src/decorators/clientKey.decorator.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { createParamDecorator, ExecutionContext } from "@nestjs/common";
|
||||
|
||||
export const ClientKey = createParamDecorator(
|
||||
(data: unknown, ctx: ExecutionContext) => {
|
||||
const request = ctx.switchToHttp().getRequest();
|
||||
|
||||
return request.user.clientKey;
|
||||
},
|
||||
);
|
||||
8
src/decorators/customeHeader.decorator.ts
Normal file
8
src/decorators/customeHeader.decorator.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { ExecutionContext, createParamDecorator } from "@nestjs/common";
|
||||
|
||||
export const CustomHeader = createParamDecorator(
|
||||
(data, ctx: ExecutionContext) => {
|
||||
console.log(ctx.switchToHttp().getRequest());
|
||||
console.log(ctx.getType());
|
||||
},
|
||||
);
|
||||
4
src/decorators/roles.decorator.ts
Normal file
4
src/decorators/roles.decorator.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { SetMetadata } from "@nestjs/common";
|
||||
import { RoleEnum } from "src/Types&Enums/role.enum";
|
||||
|
||||
export const Roles = (...args: RoleEnum[]) => SetMetadata("role", args);
|
||||
8
src/decorators/user.decorator.ts
Normal file
8
src/decorators/user.decorator.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createParamDecorator, ExecutionContext } from "@nestjs/common";
|
||||
|
||||
export const CurrentUser = createParamDecorator(
|
||||
(data: unknown, ctx: ExecutionContext) => {
|
||||
const request = ctx.switchToHttp().getRequest();
|
||||
return request.user;
|
||||
},
|
||||
);
|
||||
Reference in New Issue
Block a user