File tree Expand file tree Collapse file tree 2 files changed +66
-0
lines changed
js-core/homeworks/homework-13 Expand file tree Collapse file tree 2 files changed +66
-0
lines changed Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change 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 ( ) ;
You can’t perform that action at this time.
0 commit comments