typespeed 2.4.2 → 2.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/scaffold/templates/front-page.class.ts.tpl +12 -0
- package/dist/scaffold/templates/main.ts.tpl +13 -0
- package/dist/scaffold/templates/nodemon.json.tpl +7 -0
- package/dist/scaffold/templates/package.json.tpl +16 -0
- package/dist/scaffold/templates/tsconfig.json.tpl +20 -0
- package/dist/{src/typespeed.js → typespeed.js} +4 -1
- package/introduction/tsconfig.json +20 -0
- package/package.json +1 -1
- package/src/typespeed.ts +4 -1
- package/tsconfig.json +1 -2
- package/dist/introduction/decorator/example-import.class.js +0 -17
- package/dist/introduction/decorator/main-app.js +0 -14
- package/dist/introduction/decorator/main-decorator.js +0 -127
- package/dist/introduction/decorator/main-import.js +0 -1
- package/dist/introduction/decorator/main-reflect.js +0 -38
- package/dist/introduction/web-services/db-init.js +0 -33
- package/dist/introduction/web-services/db-singleton.js +0 -49
- package/dist/introduction/web-services/http-if.js +0 -12
- package/dist/introduction/web-services/http-init.js +0 -7
- package/dist/introduction/web-services/http-router.js +0 -23
- /package/dist/{src/core.decorator.js → core.decorator.js} +0 -0
- /package/dist/{src/database.decorator.js → database.decorator.js} +0 -0
- /package/dist/{src/default → default}/default-authentication.class.js +0 -0
- /package/dist/{src/default → default}/express-server.class.js +0 -0
- /package/dist/{src/default → default}/log-default.class.js +0 -0
- /package/dist/{src/default → default}/node-cache.class.js +0 -0
- /package/dist/{src/default → default}/pages/404.html +0 -0
- /package/dist/{src/default → default}/pages/500.html +0 -0
- /package/dist/{src/default → default}/rabbitmq.class.js +0 -0
- /package/dist/{src/default → default}/read-write-db.class.js +0 -0
- /package/dist/{src/default → default}/redis.class.js +0 -0
- /package/dist/{src/default → default}/socket-io.class.js +0 -0
- /package/dist/{src/factory → factory}/authentication-factory.class.js +0 -0
- /package/dist/{src/factory → factory}/cache-factory.class.js +0 -0
- /package/dist/{src/factory → factory}/data-source-factory.class.js +0 -0
- /package/dist/{src/factory → factory}/log-factory.class.js +0 -0
- /package/dist/{src/factory → factory}/server-factory.class.js +0 -0
- /package/dist/{src/route.decorator.js → route.decorator.js} +0 -0
- /package/dist/{src/scaffold → scaffold}/command.js +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "###appName###",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"watch": "nodemon",
|
|
6
|
+
"test": "ts-node src/main.ts",
|
|
7
|
+
"start": "ts-node --transpile-only src/main.ts",
|
|
8
|
+
"build": "tsc -p ."
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"typespeed": "latest"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@types/node": "^18.0.6"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "CommonJS",
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"emitDecoratorMetadata": true,
|
|
6
|
+
"experimentalDecorators": true,
|
|
7
|
+
"allowSyntheticDefaultImports": true,
|
|
8
|
+
"forceConsistentCasingInFileNames": true,
|
|
9
|
+
"target": "ES2017",
|
|
10
|
+
"sourceMap": true,
|
|
11
|
+
"outDir": "./dist",
|
|
12
|
+
"baseUrl": "./",
|
|
13
|
+
"typeRoots": [
|
|
14
|
+
"node_modules/@types"
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
"include": [
|
|
18
|
+
"./src/**/*.ts"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -91,7 +91,10 @@ function getRootPath(lines) {
|
|
|
91
91
|
for (let line of lines) {
|
|
92
92
|
if (line.includes(macths[matchIndex])) {
|
|
93
93
|
if (matchIndex === macths.length - 1) {
|
|
94
|
-
|
|
94
|
+
let arr = line.split("(")[1].split(":");
|
|
95
|
+
arr.pop();
|
|
96
|
+
arr.pop();
|
|
97
|
+
return arr.join(':');
|
|
95
98
|
}
|
|
96
99
|
matchIndex++;
|
|
97
100
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "CommonJS",
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"emitDecoratorMetadata": true,
|
|
6
|
+
"experimentalDecorators": true,
|
|
7
|
+
"allowSyntheticDefaultImports": true,
|
|
8
|
+
"forceConsistentCasingInFileNames": true,
|
|
9
|
+
"target": "ES2017",
|
|
10
|
+
"sourceMap": true,
|
|
11
|
+
"outDir": "./dist",
|
|
12
|
+
"baseUrl": "./",
|
|
13
|
+
"typeRoots": [
|
|
14
|
+
"node_modules/@types"
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
"include": [
|
|
18
|
+
"./**/*.ts"
|
|
19
|
+
]
|
|
20
|
+
}
|
package/package.json
CHANGED
package/src/typespeed.ts
CHANGED
|
@@ -75,7 +75,10 @@ function getRootPath(lines: string[]) {
|
|
|
75
75
|
for (let line of lines) {
|
|
76
76
|
if (line.includes(macths[matchIndex])) {
|
|
77
77
|
if(matchIndex === macths.length - 1) {
|
|
78
|
-
|
|
78
|
+
let arr = line.split("(")[1].split(":")
|
|
79
|
+
arr.pop()
|
|
80
|
+
arr.pop()
|
|
81
|
+
return arr.join(':')
|
|
79
82
|
}
|
|
80
83
|
matchIndex++;
|
|
81
84
|
}else{
|
package/tsconfig.json
CHANGED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
let ExampleImport = class ExampleImport {
|
|
10
|
-
};
|
|
11
|
-
ExampleImport = __decorate([
|
|
12
|
-
app
|
|
13
|
-
], ExampleImport);
|
|
14
|
-
exports.default = ExampleImport;
|
|
15
|
-
function app(target) {
|
|
16
|
-
console.log("import 载入 ExampleImport 类的 @app 类装饰器。");
|
|
17
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
let MainApp = class MainApp {
|
|
8
|
-
};
|
|
9
|
-
MainApp = __decorate([
|
|
10
|
-
app
|
|
11
|
-
], MainApp);
|
|
12
|
-
function app(target) {
|
|
13
|
-
console.log("执行 @app 类装饰器");
|
|
14
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
require("reflect-metadata");
|
|
16
|
-
let SecondClass = class SecondClass {
|
|
17
|
-
};
|
|
18
|
-
SecondClass = __decorate([
|
|
19
|
-
atClassWithArgs(1, 2, 3)
|
|
20
|
-
], SecondClass);
|
|
21
|
-
let FirstClass = class FirstClass {
|
|
22
|
-
get newname() {
|
|
23
|
-
return this.name;
|
|
24
|
-
}
|
|
25
|
-
changeName(name) {
|
|
26
|
-
this.name = name;
|
|
27
|
-
return new SecondClass();
|
|
28
|
-
}
|
|
29
|
-
change(name, age) {
|
|
30
|
-
this.age = age;
|
|
31
|
-
this.name = name;
|
|
32
|
-
}
|
|
33
|
-
getName() {
|
|
34
|
-
return this.name;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
__decorate([
|
|
38
|
-
atPropertyWithArgs("Li", "Mei"),
|
|
39
|
-
__metadata("design:type", String)
|
|
40
|
-
], FirstClass.prototype, "name", void 0);
|
|
41
|
-
__decorate([
|
|
42
|
-
atProperty,
|
|
43
|
-
__metadata("design:type", Number)
|
|
44
|
-
], FirstClass.prototype, "age", void 0);
|
|
45
|
-
__decorate([
|
|
46
|
-
atAccessor,
|
|
47
|
-
__metadata("design:type", String),
|
|
48
|
-
__metadata("design:paramtypes", [])
|
|
49
|
-
], FirstClass.prototype, "newname", null);
|
|
50
|
-
__decorate([
|
|
51
|
-
atMethod,
|
|
52
|
-
__metadata("design:type", Function),
|
|
53
|
-
__metadata("design:paramtypes", [String]),
|
|
54
|
-
__metadata("design:returntype", SecondClass)
|
|
55
|
-
], FirstClass.prototype, "changeName", null);
|
|
56
|
-
__decorate([
|
|
57
|
-
atMethodWithArgs("New", "Type"),
|
|
58
|
-
__param(1, atParameter),
|
|
59
|
-
__metadata("design:type", Function),
|
|
60
|
-
__metadata("design:paramtypes", [String, Number]),
|
|
61
|
-
__metadata("design:returntype", void 0)
|
|
62
|
-
], FirstClass.prototype, "change", null);
|
|
63
|
-
FirstClass = __decorate([
|
|
64
|
-
atClass
|
|
65
|
-
], FirstClass);
|
|
66
|
-
exports.default = FirstClass;
|
|
67
|
-
const obj = new FirstClass();
|
|
68
|
-
console.log("FirstClass对象调用getName()取得装饰器赋值:", obj.getName());
|
|
69
|
-
// 类装饰器
|
|
70
|
-
function atClass(target) {
|
|
71
|
-
console.log("类装饰器,类名是:", target.name);
|
|
72
|
-
}
|
|
73
|
-
// 类装饰器,带参数
|
|
74
|
-
function atClassWithArgs(...args) {
|
|
75
|
-
return function (target) {
|
|
76
|
-
console.log("类装饰器有参数,参数值:", args.join(","));
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
// 方法装饰器
|
|
80
|
-
function atMethod(target, propertyKey) {
|
|
81
|
-
const returnType = Reflect.getMetadata("design:returntype", target, propertyKey);
|
|
82
|
-
console.log("方法装饰器,获得返回类型:", returnType.name);
|
|
83
|
-
}
|
|
84
|
-
// 方法装饰器,带参数
|
|
85
|
-
function atMethodWithArgs(...args) {
|
|
86
|
-
return function (target, propertyKey) {
|
|
87
|
-
console.log("方法装饰器有参数,参数值:", args.join(","));
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
// 成员变量装饰器
|
|
91
|
-
function atProperty(target, propertyKey) {
|
|
92
|
-
const propertyType = Reflect.getMetadata("design:type", target, propertyKey);
|
|
93
|
-
console.log("变量装饰器,获得变量类型:", propertyType.name);
|
|
94
|
-
}
|
|
95
|
-
// 成员变量装饰器,带参数
|
|
96
|
-
function atPropertyWithArgs(...args) {
|
|
97
|
-
return function (target, propertyKey) {
|
|
98
|
-
console.log("变量装饰器有参数,参数值:", args.join(","));
|
|
99
|
-
Object.defineProperty(target, propertyKey, {
|
|
100
|
-
get: () => {
|
|
101
|
-
return args;
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
// 访问器装饰器
|
|
107
|
-
function atAccessor(target, propertyKey, descriptor) {
|
|
108
|
-
const returnType = Reflect.getMetadata("design:type", target, propertyKey);
|
|
109
|
-
console.log("访问器装饰器,访问器类型是:", returnType, ",值是:", target[propertyKey]);
|
|
110
|
-
}
|
|
111
|
-
// 访问器装饰器,带参数
|
|
112
|
-
function atAccessorWithArgs(...args) {
|
|
113
|
-
return function (target, propertyKey, descriptor) {
|
|
114
|
-
console.log("访问器装饰器,参数值:", args.join(","));
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
// 参数装饰器
|
|
118
|
-
function atParameter(target, propertyKey, parameterIndex) {
|
|
119
|
-
const parameterType = Reflect.getMetadata("design:paramtypes", target, propertyKey);
|
|
120
|
-
console.log("参数装饰器,参数位置在:", parameterIndex, "参数类型是:", parameterType[parameterIndex].name);
|
|
121
|
-
}
|
|
122
|
-
// 参数装饰器,带参数
|
|
123
|
-
function atParameterWithArgs(...args) {
|
|
124
|
-
return function (target, propertyKey, parameterIndex) {
|
|
125
|
-
console.log("参数装饰器有参数,参数值:", args.join(","));
|
|
126
|
-
};
|
|
127
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Promise.resolve().then(() => require("./example-import.class"));
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
require("reflect-metadata");
|
|
13
|
-
class MainReflect {
|
|
14
|
-
getAge() {
|
|
15
|
-
return this.age;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
__decorate([
|
|
19
|
-
injectAge(10),
|
|
20
|
-
__metadata("design:type", Number)
|
|
21
|
-
], MainReflect.prototype, "age", void 0);
|
|
22
|
-
__decorate([
|
|
23
|
-
findReturn,
|
|
24
|
-
__metadata("design:type", Function),
|
|
25
|
-
__metadata("design:paramtypes", []),
|
|
26
|
-
__metadata("design:returntype", Number)
|
|
27
|
-
], MainReflect.prototype, "getAge", null);
|
|
28
|
-
const mainReflect = new MainReflect();
|
|
29
|
-
console.log("获得Age值:", mainReflect.getAge());
|
|
30
|
-
function injectAge(arg) {
|
|
31
|
-
return function (target, propertyKey) {
|
|
32
|
-
Object.defineProperty(target, propertyKey, { get: () => { return arg; } });
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
function findReturn(target, propertyKey) {
|
|
36
|
-
const returnType = Reflect.getMetadata("design:returntype", target, propertyKey);
|
|
37
|
-
console.log(target[propertyKey].name, "的返回类型是:", returnType.name);
|
|
38
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const http_1 = require("http");
|
|
4
|
-
const mysql2_1 = require("mysql2");
|
|
5
|
-
class First {
|
|
6
|
-
page(response) {
|
|
7
|
-
response.end("I am first page.");
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
class User {
|
|
11
|
-
page(response) {
|
|
12
|
-
const connection = (0, mysql2_1.createConnection)({ host: 'localhost', user: 'root', "password": "qwer1234", database: 'test' });
|
|
13
|
-
connection.query('SELECT * FROM `user`', (err, results) => {
|
|
14
|
-
response.end(JSON.stringify(results));
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
class Root {
|
|
19
|
-
page(response) {
|
|
20
|
-
response.end("I am main page.");
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
const router = new Map();
|
|
24
|
-
router.set("/first", new First());
|
|
25
|
-
router.set("/main", new Root());
|
|
26
|
-
router.set("/user", new User());
|
|
27
|
-
const server = (0, http_1.createServer)((request, response) => {
|
|
28
|
-
let page = router.get(request.url === undefined ? "" : request.url);
|
|
29
|
-
if (page === undefined) {
|
|
30
|
-
page = new Root();
|
|
31
|
-
}
|
|
32
|
-
page.page(response);
|
|
33
|
-
}).listen(3000);
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const http_1 = require("http");
|
|
4
|
-
const mysql2_1 = require("mysql2");
|
|
5
|
-
class First {
|
|
6
|
-
page(response) {
|
|
7
|
-
response.end("I am first page.");
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
class User {
|
|
11
|
-
page(response) {
|
|
12
|
-
const database = Database.getInstance();
|
|
13
|
-
const databaseCopy = Database.getInstance();
|
|
14
|
-
console.log("两个对象是否一致:", database === databaseCopy);
|
|
15
|
-
database.query('SELECT * FROM `user`', (err, results) => {
|
|
16
|
-
response.end(JSON.stringify(results));
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
class Root {
|
|
21
|
-
page(response) {
|
|
22
|
-
response.end("I am main page.");
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
class Database {
|
|
26
|
-
constructor(connection) {
|
|
27
|
-
this.connection = connection;
|
|
28
|
-
}
|
|
29
|
-
static getInstance() {
|
|
30
|
-
if (!Database.instance) {
|
|
31
|
-
Database.instance = new Database((0, mysql2_1.createConnection)({ host: 'localhost', user: 'root', "password": "qwer1234", database: 'test' }));
|
|
32
|
-
}
|
|
33
|
-
return Database.instance;
|
|
34
|
-
}
|
|
35
|
-
query(sql, callback) {
|
|
36
|
-
this.connection.query('SELECT * FROM `user`', callback);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
const router = new Map();
|
|
40
|
-
router.set("/first", new First());
|
|
41
|
-
router.set("/main", new Root());
|
|
42
|
-
router.set("/user", new User());
|
|
43
|
-
const server = (0, http_1.createServer)((request, response) => {
|
|
44
|
-
let page = router.get(request.url === undefined ? "" : request.url);
|
|
45
|
-
if (page === undefined) {
|
|
46
|
-
page = new Root();
|
|
47
|
-
}
|
|
48
|
-
page.page(response);
|
|
49
|
-
}).listen(3000);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const http_1 = require("http");
|
|
4
|
-
// 使用 IF 语句来判断请求的 URL
|
|
5
|
-
const server = (0, http_1.createServer)((request, response) => {
|
|
6
|
-
if (request.url === "/first") {
|
|
7
|
-
response.end("I am first page.");
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
response.end("I am main page.");
|
|
11
|
-
}
|
|
12
|
-
}).listen(3000);
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const http_1 = require("http");
|
|
4
|
-
class First {
|
|
5
|
-
page(response) {
|
|
6
|
-
response.end("I am first page.");
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
class Root {
|
|
10
|
-
page(response) {
|
|
11
|
-
response.end("I am main page.");
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
const router = new Map();
|
|
15
|
-
router.set("/first", new First());
|
|
16
|
-
router.set("/main", new Root());
|
|
17
|
-
const server = (0, http_1.createServer)((request, response) => {
|
|
18
|
-
let page = router.get(request.url === undefined ? "" : request.url);
|
|
19
|
-
if (page === undefined) {
|
|
20
|
-
page = new Root();
|
|
21
|
-
}
|
|
22
|
-
page.page(response);
|
|
23
|
-
}).listen(3000);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|