node-http-server – Diff between revs 13 and 14

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 13 Rev 14
Line 3... Line 3...
3 /*************************************************************************/ 3 /*************************************************************************/
4 /* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */ 4 /* Copyright (C) 2017 Wizardry and Steamworks - License: GNU GPLv3 */
5 /*************************************************************************/ 5 /*************************************************************************/
Line 6... Line 6...
6   6  
7 // Import packages. -  
8 const auth = require("http-auth"); 7 // Import packages.
9 const https = require('https'); 8 const https = require('https');
10 const http = require('http'); 9 const http = require('http');
11 const path = require('path'); 10 const path = require('path');
12 const fs = require('fs'); 11 const fs = require('fs');
Line 17... Line 16...
17 const dns = require('dns'); 16 const dns = require('dns');
Line 18... Line 17...
18   17  
19 // Local imports. 18 // Local imports.
20 const handler = require( 19 const handler = require(
-   20 path
21 path 21 .resolve(
-   22 path.dirname(require.main.filename),
-   23 'src',
-   24 'handler'
22 .resolve(__dirname, 'src', 'handler') 25 )
23 ); 26 );
24 const certs = require( 27 const certs = require(
-   28 path
25 path 29 .resolve(
-   30 path.dirname(require.main.filename),
-   31 'src',
-   32 'certs'
26 .resolve(__dirname, 'src', 'certs') 33 )
Line 27... Line 34...
27 ); 34 );
28   35  
29 // Load configuration file. 36 // Load configuration file.
-   37 const config = require(
-   38 path
30 const config = require( 39 .resolve(
-   40 path.dirname(require.main.filename),
31 path 41 'config'
Line 32... Line 42...
32 .resolve(__dirname, 'config') 42 )
33 ); 43 );
34   44  
Line 46... Line 56...
46 // Create various logging mechanisms. 56 // Create various logging mechanisms.
47 const log = new winston.Logger({ 57 const log = new winston.Logger({
48 transports: [ 58 transports: [
49 new winston.transports.File({ 59 new winston.transports.File({
50 level: 'info', 60 level: 'info',
51 filename: path.resolve(__dirname, config.log.file), 61 filename: path.resolve(
-   62 path.dirname(require.main.filename),
-   63 config.log.file
-   64 ),
52 handleExceptions: true, 65 handleExceptions: true,
53 json: false, 66 json: false,
54 maxsize: 1048576, // 1MiB. 67 maxsize: 1048576, // 1MiB.
55 maxFiles: 10, // Ten rotations. 68 maxFiles: 10, // Ten rotations.
56 colorize: false, 69 colorize: false,
-   70 timestamp: () => moment()
57 timestamp: () => moment().format('YYYYMMDDTHHmmss') 71 .format('YYYYMMDDTHHmmss')
58 }), 72 }),
59 new winston.transports.Console({ 73 new winston.transports.Console({
60 level: 'info', 74 level: 'info',
61 handleExceptions: true, 75 handleExceptions: true,
62 json: false, 76 json: false,
63 colorize: true, 77 colorize: true,
-   78 timestamp: () => moment()
64 timestamp: () => moment().format('YYYYMMDDTHHmmss') 79 .format('YYYYMMDDTHHmmss')
65 }) 80 })
66 ], 81 ],
67 exitOnError: false 82 exitOnError: false
68 }); 83 });
Line 71... Line 86...
71 if (error) { 86 if (error) {
72 log.error('Could not find document root: ' + argv.root); 87 log.error('Could not find document root: ' + argv.root);
73 process.exit(1); 88 process.exit(1);
74 } 89 }
Line 75... Line -...
75   -  
76 // Create digest authentication. -  
77 const authentication = auth.digest({ -  
78 realm: config.auth.realm, -  
79 file: path.resolve(__dirname, config.auth.digest) -  
80 }); -  
81   90  
82 // Start HTTP server. 91 // Start HTTP server.
83 http.createServer( 92 http.createServer(
84 // authentication, 93 // authentication,
85 (request, response) => 94 (request, response) =>