Commit 899fb939 authored by nanahira's avatar nanahira

update RequireToken

parent 36e47044
......@@ -35,3 +35,19 @@ export function MergeParameterDecorators(
}
};
}
export function MergeClassOrMethodDecorators(
decs: (ClassDecorator & MethodDecorator)[],
): ClassDecorator & MethodDecorator {
return (obj, key?, descriptor?) => {
if (descriptor) {
for (const dec of decs) {
dec(obj, key, descriptor);
}
} else {
for (const dec of decs) {
dec(obj);
}
}
};
}
......@@ -7,7 +7,7 @@ import {
import { ConfigService } from '@nestjs/config';
import { ApiHeader } from '@nestjs/swagger';
import { BlankReturnMessageDto } from './return-message';
import { MergeMethodDecorators } from './merge';
import { MergeClassOrMethodDecorators } from './merge';
import { ApiError } from './openapi';
@Injectable()
......@@ -26,7 +26,7 @@ export class TokenGuard implements CanActivate {
}
export const RequireToken = () =>
MergeMethodDecorators([
MergeClassOrMethodDecorators([
UseGuards(TokenGuard),
ApiHeader({
name: 'x-server-token',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment