forked from svrjs/svrjs
Move commands in index.js
This commit is contained in:
parent
98c36d2b64
commit
7b4612e8b0
1 changed files with 24 additions and 21 deletions
45
src/index.js
45
src/index.js
|
@ -482,6 +482,27 @@ let middleware = [
|
||||||
require("./middleware/staticFileServingAndDirectoryListings.js"),
|
require("./middleware/staticFileServingAndDirectoryListings.js"),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// HTTP server handlers
|
||||||
|
const requestHandler = require("./handlers/requestHandler.js")(
|
||||||
|
serverconsole,
|
||||||
|
middleware,
|
||||||
|
);
|
||||||
|
|
||||||
|
const proxyHandler = require("./handlers/proxyHandler.js")(
|
||||||
|
serverconsole,
|
||||||
|
middleware,
|
||||||
|
);
|
||||||
|
|
||||||
|
const clientErrorHandler = require("./handlers/clientErrorHandler.js")(
|
||||||
|
serverconsole,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Create HTTP server
|
||||||
|
const server = http
|
||||||
|
.createServer(requestHandler)
|
||||||
|
.on("connect", proxyHandler)
|
||||||
|
.on("clientError", clientErrorHandler);
|
||||||
|
|
||||||
// TODO: close, open, stop, restart commands
|
// TODO: close, open, stop, restart commands
|
||||||
// Base commands
|
// Base commands
|
||||||
let commands = {
|
let commands = {
|
||||||
|
@ -525,27 +546,9 @@ middleware.forEach((middlewareO) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// HTTP server handlers
|
// TODO: HTTP ports
|
||||||
const requestHandler = require("./handlers/requestHandler.js")(
|
// Listen HTTP server to port 3000
|
||||||
serverconsole,
|
server.listen(3000);
|
||||||
middleware,
|
|
||||||
);
|
|
||||||
|
|
||||||
const proxyHandler = require("./handlers/proxyHandler.js")(
|
|
||||||
serverconsole,
|
|
||||||
middleware,
|
|
||||||
);
|
|
||||||
|
|
||||||
const clientErrorHandler = require("./handlers/clientErrorHandler.js")(
|
|
||||||
serverconsole,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Create HTTP server
|
|
||||||
http
|
|
||||||
.createServer(requestHandler)
|
|
||||||
.on("connect", proxyHandler)
|
|
||||||
.on("clientError", clientErrorHandler)
|
|
||||||
.listen(3000);
|
|
||||||
|
|
||||||
// TODO: error logging
|
// TODO: error logging
|
||||||
if (wwwrootError) throw wwwrootError;
|
if (wwwrootError) throw wwwrootError;
|
||||||
|
|
Reference in a new issue