FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
adminforth/adminforth/modules/requestContext.ts at test · devforth/adminforth · GitHub
devforth
adminforth
Repository navigation
Code
Issues
16
(16)
Pull requests
4
(4)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
adminforth
/
adminforth
/
modules
/
requestContext.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
21 lines (15 loc) · 689 Bytes
Breadcrumbs
adminforth
/
adminforth
/
modules
/
requestContext.ts
Copy path
File metadata and controls
21 lines (15 loc) · 689 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import
{
AsyncLocalStorage
}
from
'async_hooks'
;
export
const
ADMINFORTH_CLIENT_ID_HEADER
=
'x-adminforth-client-id'
;
export
type
AdminForthRequestContext
=
{
websocketClientId
?:
string
;
}
;
const
requestContextStorage
=
new
AsyncLocalStorage
<
AdminForthRequestContext
>
(
)
;
export
function
runWithRequestContext
<
T
>
(
context
:
AdminForthRequestContext
,
callback
:
(
)
=>
T
)
:
T
{
return
requestContextStorage
.
run
(
context
,
callback
)
;
}
export
function
getRequestContext
(
)
:
AdminForthRequestContext
|
undefined
{
return
requestContextStorage
.
getStore
(
)
;
}
export
function
getRequestWebsocketClientId
(
)
:
string
|
undefined
{
return
requestContextStorage
.
getStore
(
)
?.
websocketClientId
;
}
Back
|
FazBrowse Home
|
New Git URL