-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
74 lines (49 loc) · 1.19 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//basics
function prHelo(name){
console.log('Hello\t'+name);
}
prHelo('wassssa\n');
//module structure
console.log(module);
console.log('\n');
//load a module
//const logger = require('./logger');
//logger.log('Wassssa\n');
//path module (built-in)
const path = require('path');
var pathObj = path.parse(__filename);
console.log(pathObj);
console.log('\n');
//os module
const os = require('os');
console.log('Total memory: ' + os.totalmem());
console.log(`Free Memory: ${os.freemem()}`);
console.log('\n');
//fs module
const fs = require('fs');
fs.readdir('./',function(err, files){
if(err) console.log('Error: '+err);
else console.log(files);
})
//event module
const EventEmitter = require('events');
const Logger = require('./logger');
const loggr = new Logger();
loggr.on('messageLogged', (eventArg) => {
console.log('Listener is called\n',eventArg);
});
loggr.log('wassssa');
//http module
const http = require('http');
const server = http.createServer((req,res) => {
if(req.url === '/'){
res.write('Wassssa');
res.end();
}
if(req.url === '/abc'){
res.write(JSON.stringify(['a','b','c']));
res.end();
}
});
server.listen(3000);
console.log('Listening on port 3000...')