-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
29 lines (27 loc) · 1.02 KB
/
server.js
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
var WebDevServer = require("web-dev-server");
//var WebDevServer = require("../web-dev-server/build/lib/Server");
// Create web server instance.
WebDevServer.Server.CreateNew()
// Required.
.SetDocumentRoot(__dirname)
// Optional, 8000 by default.
.SetPort(8000)
// Optional, '127.0.0.1' by default.
.SetHostname('127.0.0.1')
// Optional, `true` by default to display Errors and directories.
//.SetDevelopment(false)
// Optional, `null` by default, useful for apache proxy modes.
//.SetBaseUrl('/chat')
// Optional, to prepend any execution before `web-dev-server` module execution.
.AddPreHandler(async function (req, res, event) {
if (req.GetPath() == '/health') {
res.SetCode(200).SetBody('1').Send();
// Do not anything else in `web-dev-server` module for this request:
event.PreventDefault();
}
})
// Callback param is optional. called after server has been started or after error ocured.
.Start(function (success, err) {
if (!success) return console.error(err);
console.log("Server is running.");
});