Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Nesties
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Nesties
Commits
899fb939
Commit
899fb939
authored
Oct 28, 2024
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update RequireToken
parent
36e47044
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
src/merge.ts
src/merge.ts
+16
-0
src/token.guard.ts
src/token.guard.ts
+2
-2
No files found.
src/merge.ts
View file @
899fb939
...
@@ -35,3 +35,19 @@ export function MergeParameterDecorators(
...
@@ -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
);
}
}
};
}
src/token.guard.ts
View file @
899fb939
...
@@ -7,7 +7,7 @@ import {
...
@@ -7,7 +7,7 @@ import {
import
{
ConfigService
}
from
'
@nestjs/config
'
;
import
{
ConfigService
}
from
'
@nestjs/config
'
;
import
{
ApiHeader
}
from
'
@nestjs/swagger
'
;
import
{
ApiHeader
}
from
'
@nestjs/swagger
'
;
import
{
BlankReturnMessageDto
}
from
'
./return-message
'
;
import
{
BlankReturnMessageDto
}
from
'
./return-message
'
;
import
{
MergeMethodDecorators
}
from
'
./merge
'
;
import
{
Merge
ClassOr
MethodDecorators
}
from
'
./merge
'
;
import
{
ApiError
}
from
'
./openapi
'
;
import
{
ApiError
}
from
'
./openapi
'
;
@
Injectable
()
@
Injectable
()
...
@@ -26,7 +26,7 @@ export class TokenGuard implements CanActivate {
...
@@ -26,7 +26,7 @@ export class TokenGuard implements CanActivate {
}
}
export
const
RequireToken
=
()
=>
export
const
RequireToken
=
()
=>
MergeMethodDecorators
([
Merge
ClassOr
MethodDecorators
([
UseGuards
(
TokenGuard
),
UseGuards
(
TokenGuard
),
ApiHeader
({
ApiHeader
({
name
:
'
x-server-token
'
,
name
:
'
x-server-token
'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment