FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
web-frameworks/javascript/hapi/app.js at develop · SimplifyNet/web-frameworks · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
SimplifyNet
/
web-frameworks
Public
forked from
the-benchmarker/web-frameworks
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
web-frameworks
/
javascript
/
hapi
/
app.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
49 lines (41 loc) · 907 Bytes
Breadcrumbs
web-frameworks
/
javascript
/
hapi
/
app.js
Copy path
File metadata and controls
49 lines (41 loc) · 907 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const
Hapi
=
require
(
'@hapi/hapi'
)
;
// Workers can share any TCP connection
// In this case it is an HTTP server
// Create a server with a host and port
const
server
=
Hapi
.
server
(
{
host
:
'0.0.0.0'
,
port
:
3000
,
}
)
;
// Add the route
server
.
route
(
{
method
:
'GET'
,
path
:
'/'
,
handler
:
function
(
req
,
handler
)
{
return
handler
.
response
(
''
)
.
header
(
'Content-Length'
,
'0'
)
;
}
,
}
)
;
server
.
route
(
{
method
:
'GET'
,
path
:
'/user/{id}'
,
handler
:
function
(
req
,
handler
)
{
return
req
.
params
.
id
;
}
,
}
)
;
server
.
route
(
{
method
:
'POST'
,
path
:
'/user'
,
handler
:
function
(
req
,
handler
)
{
return
handler
.
response
(
''
)
.
header
(
'Content-Length'
,
'0'
)
;
}
,
}
)
;
// Start the server
async
function
start
(
)
{
try
{
await
server
.
start
(
)
;
}
catch
(
err
)
{
console
.
log
(
err
)
;
process
.
exit
(
1
)
;
}
console
.
log
(
`Worker
${
process
.
pid
}
running at:`
,
server
.
info
.
uri
)
;
}
start
(
)
;
Back
|
FazBrowse Home
|
New Git URL