-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
51 lines (41 loc) · 1.43 KB
/
app.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
var connect = require('connect');
serveStatic = require('serve-static');
network = require('network');
winston = require('winston');
port = process.env.PORT || 8080;
liveReload = require('livereload');
project = require('./package.json');
// lets create a global logger
const logger = winston.createLogger({
level: 'info',
format: winston.format.json(),
transports: [
new winston.transports.Console({
level: 'info',
format: winston.format.combine(
winston.format.colorize(),
winston.format.simple()
)
})
]
});
connect().use('/' + project.name, serveStatic(__dirname)).listen(port)
var liveReloadServer = liveReload.createServer()
liveReloadServer.watch(__dirname)
logger.info('Running:')
logger.info('\t' + project.name)
logger.info('LiveReload Server is watching:')
logger.info('\t' + __dirname)
network.get_active_interface(function(err, obj) {
var address = `:${port}/${project.name}`;
logger.info('The magic happens at')
logger.info('\t Localhost: http://localhost' + address)
network.get_public_ip(function(err, ip) {
// should return your public IP address
logger.info("\t Public IP:", err || ip + address);
})
network.get_private_ip(function(err, ip) {
// err may be 'No active network interface found'.
logger.info("\t Private IP:", err || ip + address);
})
});