FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Ackee/src/utils/createContext.js at develop · electerious/Ackee · GitHub
electerious
/
Ackee
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
386
Star
4.7k
Code
Issues
33
Pull requests
5
Discussions
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
Ackee
/
src
/
utils
/
createContext.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
30 lines (26 loc) · 996 Bytes
Breadcrumbs
Ackee
/
src
/
utils
/
createContext.js
Copy path
File metadata and controls
30 lines (26 loc) · 996 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
22
23
24
25
26
27
28
29
30
import
{
getClientIp
}
from
'request-ip'
import
config
from
'./config.js'
import
createDate
from
'./createDate.js'
import
{
isSet
}
from
'./ignoreCookie.js'
import
isAuthenticated
from
'./isAuthenticated.js'
export
const
createServerlessContext
=
(
request
)
=>
{
const
ip
=
request
.
headers
.
get
(
'x-forwarded-for'
)
?.
split
(
','
)
[
0
]
?.
trim
(
)
||
request
.
headers
.
get
(
'x-real-ip'
)
const
headers
=
Object
.
fromEntries
(
request
.
headers
)
return
createContext
(
ip
,
headers
)
}
export
const
createExpressContext
=
(
{
req
}
)
=>
{
return
createContext
(
getClientIp
(
req
)
,
req
.
headers
)
}
const
createContext
=
async
(
ip
,
headers
)
=>
{
return
{
isDemoMode
:
config
.
isDemoMode
,
isAuthenticated
:
await
isAuthenticated
(
headers
[
'authorization'
]
,
config
.
ttl
)
,
isIgnored
:
isSet
(
headers
[
'cookie'
]
)
,
dateDetails
:
createDate
(
headers
[
'time-zone'
]
)
,
userAgent
:
headers
[
'user-agent'
]
,
ip
,
// Variables used by to set and read cookies and headers
setCookies
:
[
]
,
setHeaders
:
[
]
,
}
}
Back
|
FazBrowse Home
|
New Git URL