Skip to content

Commit e65dd72

Browse files
authored
Merge pull request #15 from EasyCode-JavaScriptReact-v1/homework_13
homework_13
2 parents 03d867b + ca6f557 commit e65dd72

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Home work 13</title>
6+
</head>
7+
<body>
8+
9+
<script src="src/main.js"></script>
10+
</body>
11+
</html>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
//Task1 (hw12 ---> task1)
2+
class Http {
3+
constructor() {
4+
this.ctx = {
5+
req: {
6+
PORT: 'number',
7+
url: 'string'
8+
},
9+
res: {
10+
status: 'number',
11+
message: 'string',
12+
header: {
13+
content_type: 'application/json'
14+
}
15+
}
16+
},
17+
this.next = () => {}
18+
};
19+
20+
createServer(fn) {
21+
this.createServerCallback = fn;
22+
return this;
23+
};
24+
listen(PORT, host) {
25+
console.log(`Server running on https://${host}:${PORT}`);
26+
this.createServerCallback(this.ctx, this.next);
27+
};
28+
};
29+
30+
const server = new Http().createServer(function(ctx, next) {
31+
console.log(ctx);
32+
}).listen(3000, 'localhost');
33+
34+
35+
//Task2
36+
37+
class DataBase {
38+
constructor() {
39+
this.idSetTimeout;
40+
};
41+
42+
time() {
43+
clearTimeout(this.idSetTimeout);
44+
this.idSetTimeout = setTimeout(function(){
45+
console.log('The web server is down');
46+
}, 5000);
47+
};
48+
49+
query() {
50+
this.time();
51+
};
52+
};
53+
54+
const dataBase = new DataBase();
55+
dataBase.query();

0 commit comments

Comments
 (0)