FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
edge-react-gui/scripts/loggingServer.ts at develop · EdgeApp/edge-react-gui · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
EdgeApp
/
edge-react-gui
Public
Notifications
You must be signed in to change notification settings
Fork
293
Star
519
Code
Issues
51
Pull requests
144
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
edge-react-gui
/
scripts
/
loggingServer.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
56 lines (47 loc) · 1.21 KB
Breadcrumbs
edge-react-gui
/
scripts
/
loggingServer.ts
Copy path
File metadata and controls
56 lines (47 loc) · 1.21 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import
bodyParser
from
'body-parser'
import
express
from
'express'
import
fs
from
'fs'
import
os
from
'os'
const
ifaces
=
os
.
networkInterfaces
(
)
const
PORT
=
8080
const
envFile
=
'./env.json'
let
address
=
''
let
envJSON
=
{
LOG_SERVER
:
{
}
}
try
{
envJSON
=
JSON
.
parse
(
fs
.
readFileSync
(
envFile
,
'utf8'
)
)
}
catch
(
e
)
{
console
.
log
(
e
)
}
try
{
// Get Local Host Address
Object
.
keys
(
ifaces
)
.
forEach
(
function
(
ifname
)
{
let
found
=
false
const
iface
=
ifaces
[
ifname
]
??
[
]
iface
.
forEach
(
function
(
iface
)
{
if
(
iface
.
family
!==
'IPv4'
||
iface
.
internal
)
{
// skip over internal (i.e. 127.0.0.1) and non-ipv4 addresses
return
}
if
(
found
)
return
address
=
iface
.
address
found
=
true
}
)
}
)
// Set env.json with correct path
envJSON
.
LOG_SERVER
=
{
host
:
`http://
${
address
}
`
,
port
:
`
${
PORT
}
`
}
fs
.
writeFileSync
(
envFile
,
JSON
.
stringify
(
envJSON
,
null
,
2
)
)
}
catch
(
e
)
{
console
.
log
(
e
)
}
// Run the logging server
const
app
=
express
(
)
app
.
use
(
bodyParser
.
json
(
)
)
app
.
use
(
bodyParser
.
urlencoded
(
{
extended
:
true
}
)
)
app
.
post
(
'/log'
,
function
(
req
,
res
)
{
if
(
req
.
body
?.
data
)
console
.
log
(
req
.
body
.
data
.
toString
(
)
)
res
.
sendStatus
(
200
)
}
)
app
.
listen
(
PORT
)
Back
|
FazBrowse Home
|
New Git URL