-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
55 lines (47 loc) · 931 Bytes
/
main.js
File metadata and controls
55 lines (47 loc) · 931 Bytes
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
//Task1 (hw12 ---> task1)
class Http {
constructor() {
this.ctx = {
req: {
PORT: 'number',
url: 'string'
},
res: {
status: 'number',
message: 'string',
header: {
content_type: 'application/json'
}
}
},
this.next = () => {}
};
createServer(fn) {
this.createServerCallback = fn;
return this;
};
listen(PORT, host) {
console.log(`Server running on https://${host}:${PORT}`);
this.createServerCallback(this.ctx, this.next);
};
};
const server = new Http().createServer(function(ctx, next) {
console.log(ctx);
}).listen(3000, 'localhost');
//Task2
class DataBase {
constructor() {
this.idSetTimeout;
};
time() {
clearTimeout(this.idSetTimeout);
this.idSetTimeout = setTimeout(function(){
console.log('The web server is down');
}, 5000);
};
query() {
this.time();
};
};
const dataBase = new DataBase();
dataBase.query();