typespeed 2.0.6 → 2.0.7

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.
Files changed (184) hide show
  1. package/dist/core.decorator.js +1 -1
  2. package/dist/core.decorator.js.map +1 -1
  3. package/introduction/decorator/example-import.class.ts +6 -0
  4. package/introduction/decorator/main-app.ts +6 -0
  5. package/introduction/decorator/main-decorator.ts +108 -0
  6. package/introduction/decorator/main-import.ts +1 -0
  7. package/introduction/decorator/main-reflect.ts +25 -0
  8. package/introduction/web-services/db-init.ts +39 -0
  9. package/introduction/web-services/db-singleton.ts +59 -0
  10. package/introduction/web-services/http-if.ts +10 -0
  11. package/introduction/web-services/http-init.ts +6 -0
  12. package/introduction/web-services/http-router.ts +28 -0
  13. package/package.json +2 -2
  14. package/src/core.decorator.ts +1 -1
  15. package/test/node_modules/.package-lock.json +62 -0
  16. package/test/node_modules/@types/node/LICENSE +21 -0
  17. package/test/node_modules/@types/node/README.md +16 -0
  18. package/test/node_modules/@types/node/assert/strict.d.ts +8 -0
  19. package/test/node_modules/@types/node/assert.d.ts +961 -0
  20. package/test/node_modules/@types/node/async_hooks.d.ts +518 -0
  21. package/test/node_modules/@types/node/buffer.d.ts +2320 -0
  22. package/test/node_modules/@types/node/child_process.d.ts +1372 -0
  23. package/test/node_modules/@types/node/cluster.d.ts +410 -0
  24. package/test/node_modules/@types/node/console.d.ts +412 -0
  25. package/test/node_modules/@types/node/constants.d.ts +18 -0
  26. package/test/node_modules/@types/node/crypto.d.ts +3973 -0
  27. package/test/node_modules/@types/node/dgram.d.ts +545 -0
  28. package/test/node_modules/@types/node/diagnostics_channel.d.ts +192 -0
  29. package/test/node_modules/@types/node/dns/promises.d.ts +370 -0
  30. package/test/node_modules/@types/node/dns.d.ts +660 -0
  31. package/test/node_modules/@types/node/dom-events.d.ts +126 -0
  32. package/test/node_modules/@types/node/domain.d.ts +170 -0
  33. package/test/node_modules/@types/node/events.d.ts +682 -0
  34. package/test/node_modules/@types/node/fs/promises.d.ts +1159 -0
  35. package/test/node_modules/@types/node/fs.d.ts +3976 -0
  36. package/test/node_modules/@types/node/globals.d.ts +302 -0
  37. package/test/node_modules/@types/node/globals.global.d.ts +1 -0
  38. package/test/node_modules/@types/node/http.d.ts +1714 -0
  39. package/test/node_modules/@types/node/http2.d.ts +2133 -0
  40. package/test/node_modules/@types/node/https.d.ts +542 -0
  41. package/test/node_modules/@types/node/index.d.ts +134 -0
  42. package/test/node_modules/@types/node/inspector.d.ts +2741 -0
  43. package/test/node_modules/@types/node/module.d.ts +115 -0
  44. package/test/node_modules/@types/node/net.d.ts +883 -0
  45. package/test/node_modules/@types/node/os.d.ts +473 -0
  46. package/test/node_modules/@types/node/package.json +237 -0
  47. package/test/node_modules/@types/node/path.d.ts +191 -0
  48. package/test/node_modules/@types/node/perf_hooks.d.ts +625 -0
  49. package/test/node_modules/@types/node/process.d.ts +1488 -0
  50. package/test/node_modules/@types/node/punycode.d.ts +117 -0
  51. package/test/node_modules/@types/node/querystring.d.ts +131 -0
  52. package/test/node_modules/@types/node/readline/promises.d.ts +143 -0
  53. package/test/node_modules/@types/node/readline.d.ts +653 -0
  54. package/test/node_modules/@types/node/repl.d.ts +424 -0
  55. package/test/node_modules/@types/node/stream/consumers.d.ts +12 -0
  56. package/test/node_modules/@types/node/stream/promises.d.ts +42 -0
  57. package/test/node_modules/@types/node/stream/web.d.ts +330 -0
  58. package/test/node_modules/@types/node/stream.d.ts +1440 -0
  59. package/test/node_modules/@types/node/string_decoder.d.ts +67 -0
  60. package/test/node_modules/@types/node/test.d.ts +760 -0
  61. package/test/node_modules/@types/node/timers/promises.d.ts +93 -0
  62. package/test/node_modules/@types/node/timers.d.ts +101 -0
  63. package/test/node_modules/@types/node/tls.d.ts +1111 -0
  64. package/test/node_modules/@types/node/trace_events.d.ts +171 -0
  65. package/test/node_modules/@types/node/ts4.8/assert/strict.d.ts +8 -0
  66. package/test/node_modules/@types/node/ts4.8/assert.d.ts +961 -0
  67. package/test/node_modules/@types/node/ts4.8/async_hooks.d.ts +518 -0
  68. package/test/node_modules/@types/node/ts4.8/buffer.d.ts +2320 -0
  69. package/test/node_modules/@types/node/ts4.8/child_process.d.ts +1372 -0
  70. package/test/node_modules/@types/node/ts4.8/cluster.d.ts +410 -0
  71. package/test/node_modules/@types/node/ts4.8/console.d.ts +412 -0
  72. package/test/node_modules/@types/node/ts4.8/constants.d.ts +18 -0
  73. package/test/node_modules/@types/node/ts4.8/crypto.d.ts +3972 -0
  74. package/test/node_modules/@types/node/ts4.8/dgram.d.ts +545 -0
  75. package/test/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +192 -0
  76. package/test/node_modules/@types/node/ts4.8/dns/promises.d.ts +370 -0
  77. package/test/node_modules/@types/node/ts4.8/dns.d.ts +660 -0
  78. package/test/node_modules/@types/node/ts4.8/dom-events.d.ts +126 -0
  79. package/test/node_modules/@types/node/ts4.8/domain.d.ts +170 -0
  80. package/test/node_modules/@types/node/ts4.8/events.d.ts +682 -0
  81. package/test/node_modules/@types/node/ts4.8/fs/promises.d.ts +1138 -0
  82. package/test/node_modules/@types/node/ts4.8/fs.d.ts +3875 -0
  83. package/test/node_modules/@types/node/ts4.8/globals.d.ts +301 -0
  84. package/test/node_modules/@types/node/ts4.8/globals.global.d.ts +1 -0
  85. package/test/node_modules/@types/node/ts4.8/http.d.ts +1651 -0
  86. package/test/node_modules/@types/node/ts4.8/http2.d.ts +2133 -0
  87. package/test/node_modules/@types/node/ts4.8/https.d.ts +542 -0
  88. package/test/node_modules/@types/node/ts4.8/index.d.ts +88 -0
  89. package/test/node_modules/@types/node/ts4.8/inspector.d.ts +2741 -0
  90. package/test/node_modules/@types/node/ts4.8/module.d.ts +115 -0
  91. package/test/node_modules/@types/node/ts4.8/net.d.ts +883 -0
  92. package/test/node_modules/@types/node/ts4.8/os.d.ts +473 -0
  93. package/test/node_modules/@types/node/ts4.8/path.d.ts +191 -0
  94. package/test/node_modules/@types/node/ts4.8/perf_hooks.d.ts +625 -0
  95. package/test/node_modules/@types/node/ts4.8/process.d.ts +1488 -0
  96. package/test/node_modules/@types/node/ts4.8/punycode.d.ts +117 -0
  97. package/test/node_modules/@types/node/ts4.8/querystring.d.ts +131 -0
  98. package/test/node_modules/@types/node/ts4.8/readline/promises.d.ts +143 -0
  99. package/test/node_modules/@types/node/ts4.8/readline.d.ts +653 -0
  100. package/test/node_modules/@types/node/ts4.8/repl.d.ts +424 -0
  101. package/test/node_modules/@types/node/ts4.8/stream/consumers.d.ts +12 -0
  102. package/test/node_modules/@types/node/ts4.8/stream/promises.d.ts +42 -0
  103. package/test/node_modules/@types/node/ts4.8/stream/web.d.ts +330 -0
  104. package/test/node_modules/@types/node/ts4.8/stream.d.ts +1440 -0
  105. package/test/node_modules/@types/node/ts4.8/string_decoder.d.ts +67 -0
  106. package/test/node_modules/@types/node/ts4.8/test.d.ts +760 -0
  107. package/test/node_modules/@types/node/ts4.8/timers/promises.d.ts +93 -0
  108. package/test/node_modules/@types/node/ts4.8/timers.d.ts +94 -0
  109. package/test/node_modules/@types/node/ts4.8/tls.d.ts +1111 -0
  110. package/test/node_modules/@types/node/ts4.8/trace_events.d.ts +171 -0
  111. package/test/node_modules/@types/node/ts4.8/tty.d.ts +206 -0
  112. package/test/node_modules/@types/node/ts4.8/url.d.ts +902 -0
  113. package/test/node_modules/@types/node/ts4.8/util.d.ts +2017 -0
  114. package/test/node_modules/@types/node/ts4.8/v8.d.ts +541 -0
  115. package/test/node_modules/@types/node/ts4.8/vm.d.ts +644 -0
  116. package/test/node_modules/@types/node/ts4.8/wasi.d.ts +158 -0
  117. package/test/node_modules/@types/node/ts4.8/worker_threads.d.ts +695 -0
  118. package/test/node_modules/@types/node/ts4.8/zlib.d.ts +517 -0
  119. package/test/node_modules/@types/node/tty.d.ts +206 -0
  120. package/test/node_modules/@types/node/url.d.ts +902 -0
  121. package/test/node_modules/@types/node/util.d.ts +2017 -0
  122. package/test/node_modules/@types/node/v8.d.ts +541 -0
  123. package/test/node_modules/@types/node/vm.d.ts +644 -0
  124. package/test/node_modules/@types/node/wasi.d.ts +158 -0
  125. package/test/node_modules/@types/node/worker_threads.d.ts +695 -0
  126. package/test/node_modules/@types/node/zlib.d.ts +517 -0
  127. package/test/node_modules/colors/LICENSE +25 -0
  128. package/test/node_modules/colors/README.md +221 -0
  129. package/test/node_modules/colors/examples/normal-usage.js +82 -0
  130. package/test/node_modules/colors/examples/safe-string.js +79 -0
  131. package/test/node_modules/colors/index.d.ts +136 -0
  132. package/test/node_modules/colors/lib/colors.js +211 -0
  133. package/test/node_modules/colors/lib/custom/trap.js +46 -0
  134. package/test/node_modules/colors/lib/custom/zalgo.js +110 -0
  135. package/test/node_modules/colors/lib/extendStringPrototype.js +110 -0
  136. package/test/node_modules/colors/lib/index.js +13 -0
  137. package/test/node_modules/colors/lib/maps/america.js +10 -0
  138. package/test/node_modules/colors/lib/maps/rainbow.js +12 -0
  139. package/test/node_modules/colors/lib/maps/random.js +11 -0
  140. package/test/node_modules/colors/lib/maps/zebra.js +5 -0
  141. package/test/node_modules/colors/lib/styles.js +95 -0
  142. package/test/node_modules/colors/lib/system/has-flag.js +35 -0
  143. package/test/node_modules/colors/lib/system/supports-colors.js +151 -0
  144. package/test/node_modules/colors/package.json +45 -0
  145. package/test/node_modules/colors/safe.d.ts +48 -0
  146. package/test/node_modules/colors/safe.js +10 -0
  147. package/test/node_modules/colors/themes/generic-logging.js +12 -0
  148. package/test/node_modules/dateformat/LICENSE +20 -0
  149. package/test/node_modules/dateformat/Readme.md +204 -0
  150. package/test/node_modules/dateformat/lib/dateformat.js +1 -0
  151. package/test/node_modules/dateformat/package.json +38 -0
  152. package/test/node_modules/mkdirp/CHANGELOG.md +15 -0
  153. package/test/node_modules/mkdirp/LICENSE +21 -0
  154. package/test/node_modules/mkdirp/bin/cmd.js +68 -0
  155. package/test/node_modules/mkdirp/index.js +31 -0
  156. package/test/node_modules/mkdirp/lib/find-made.js +29 -0
  157. package/test/node_modules/mkdirp/lib/mkdirp-manual.js +64 -0
  158. package/test/node_modules/mkdirp/lib/mkdirp-native.js +39 -0
  159. package/test/node_modules/mkdirp/lib/opts-arg.js +23 -0
  160. package/test/node_modules/mkdirp/lib/path-arg.js +29 -0
  161. package/test/node_modules/mkdirp/lib/use-native.js +10 -0
  162. package/test/node_modules/mkdirp/package.json +44 -0
  163. package/test/node_modules/mkdirp/readme.markdown +266 -0
  164. package/test/node_modules/tinytim/.travis.yml +5 -0
  165. package/test/node_modules/tinytim/README.md +212 -0
  166. package/test/node_modules/tinytim/index.js +1 -0
  167. package/test/node_modules/tinytim/lib/index.js +55 -0
  168. package/test/node_modules/tinytim/lib/tinytim.js +50 -0
  169. package/test/node_modules/tinytim/package.json +24 -0
  170. package/test/node_modules/tinytim/test/files/html.tim +1 -0
  171. package/test/node_modules/tinytim/test/files/string.tim +1 -0
  172. package/test/node_modules/tinytim/test/files/string2.tim +1 -0
  173. package/test/node_modules/tinytim/test/render-file-replace.js +39 -0
  174. package/test/node_modules/tinytim/test/render-replace.js +94 -0
  175. package/test/node_modules/tinytim/test/tim-replace.js +95 -0
  176. package/test/node_modules/tracer/README.md +747 -0
  177. package/test/node_modules/tracer/lib/color_console.js +15 -0
  178. package/test/node_modules/tracer/lib/console.js +165 -0
  179. package/test/node_modules/tracer/lib/dailyfile.js +92 -0
  180. package/test/node_modules/tracer/lib/index.js +10 -0
  181. package/test/node_modules/tracer/lib/settings.js +25 -0
  182. package/test/node_modules/tracer/lib/utils.js +58 -0
  183. package/test/node_modules/tracer/package.json +53 -0
  184. package/test/node_modules/tracer/types/index.d.ts +189 -0
@@ -23,7 +23,7 @@ if (fs.existsSync(configFile)) {
23
23
  }
24
24
  }
25
25
  function app(constructor) {
26
- const coreFiles = walkSync(coreDir, { globs: ['**/*.ts'] });
26
+ const coreFiles = walkSync(coreDir, { globs: ['**/*.ts'], ignore: ['**/*.d.ts', 'scaffold/**'] });
27
27
  const mainFiles = walkSync(mainPath, { globs: ['**/*.ts'] });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B;IAClD,MAAM,UAAU,GAAG,YAAY,CAAC,mBAAmB,CAAC,CAAC;IACrD,OAAO,UAAU,MAAM,EAAE,WAAmB;QACxC,MAAM,aAAa,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;QAC7C,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE;YACtB,CAAC,UAAU,CAAC,EAAE,UAAU,GAAG,IAAI;gBAC3B,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;gBACrD,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;gBAChD,GAAG,CAAC,6BAA6B,CAAC,CAAC;gBACnC,OAAO,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,MAAM,CAAC;YACjC,CAAC;SACJ,CAAC,CAAA;IACN,CAAC,CAAC;AACN,CAAC;AAQqD,sBAAK;AAN3D,SAAS,QAAQ,CAAC,QAAuB;IACrC,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAE,EAAE;QACxC,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC;IAC5D,CAAC,CAAA;AACL,CAAC;AAEmH,4BAAQ"}
@@ -0,0 +1,6 @@
1
+ @app
2
+ export default class ExampleImport {}
3
+
4
+ function app(target: any) {
5
+ console.log("import 载入 ExampleImport 类的 @app 类装饰器。");
6
+ }
@@ -0,0 +1,6 @@
1
+ @app
2
+ class MainApp {}
3
+
4
+ function app(target: any) {
5
+ console.log("执行 @app 类装饰器");
6
+ }
@@ -0,0 +1,108 @@
1
+ import "reflect-metadata";
2
+
3
+ @atClassWithArgs(1, 2, 3)
4
+ class SecondClass {}
5
+
6
+ @atClass
7
+ export default class FirstClass {
8
+
9
+ @atPropertyWithArgs("Li", "Mei")
10
+ private name: string;
11
+
12
+ @atProperty
13
+ private age: number;
14
+
15
+ @atAccessor
16
+ get newname(): string {
17
+ return this.name;
18
+ }
19
+
20
+ @atMethod
21
+ changeName(name: string): SecondClass {
22
+ this.name = name;
23
+ return new SecondClass();
24
+ }
25
+
26
+ @atMethodWithArgs("New", "Type")
27
+ change(name: string, @atParameter age: number): void {
28
+ this.age = age;
29
+ this.name = name;
30
+ }
31
+
32
+ getName(): string {
33
+ return this.name;
34
+ }
35
+ }
36
+
37
+ const obj = new FirstClass();
38
+
39
+ console.log("FirstClass对象调用getName()取得装饰器赋值:", obj.getName());
40
+
41
+ // 类装饰器
42
+ function atClass(target: any) {
43
+ console.log("类装饰器,类名是:", target.name);
44
+ }
45
+
46
+ // 类装饰器,带参数
47
+ function atClassWithArgs(...args: any[]) {
48
+ return function (target: any) {
49
+ console.log("类装饰器有参数,参数值:", args.join(","));
50
+ }
51
+ }
52
+
53
+ // 方法装饰器
54
+ function atMethod(target: any, propertyKey: string) {
55
+ const returnType: any = Reflect.getMetadata("design:returntype", target, propertyKey);
56
+ console.log("方法装饰器,获得返回类型:", returnType.name);
57
+ }
58
+
59
+ // 方法装饰器,带参数
60
+ function atMethodWithArgs(...args: any[]) {
61
+ return function (target: any, propertyKey: string) {
62
+ console.log("方法装饰器有参数,参数值:", args.join(","));
63
+ }
64
+ }
65
+
66
+ // 成员变量装饰器
67
+ function atProperty(target: any, propertyKey: string) {
68
+ const propertyType: any = Reflect.getMetadata("design:type", target, propertyKey);
69
+ console.log("变量装饰器,获得变量类型:", propertyType.name);
70
+ }
71
+
72
+ // 成员变量装饰器,带参数
73
+ function atPropertyWithArgs(...args: any[]) {
74
+ return function (target: any, propertyKey: string) {
75
+ console.log("变量装饰器有参数,参数值:", args.join(","));
76
+ Object.defineProperty(target, propertyKey, {
77
+ get: () => {
78
+ return args;
79
+ }
80
+ });
81
+ }
82
+ }
83
+
84
+ // 访问器装饰器
85
+ function atAccessor(target: any, propertyKey: string, descriptor: PropertyDescriptor) {
86
+ const returnType: any = Reflect.getMetadata("design:type", target, propertyKey);
87
+ console.log("访问器装饰器,访问器类型是:", returnType, ",值是:", target[propertyKey]);
88
+ }
89
+
90
+ // 访问器装饰器,带参数
91
+ function atAccessorWithArgs(...args: any[]) {
92
+ return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
93
+ console.log("访问器装饰器,参数值:", args.join(","));
94
+ }
95
+ }
96
+
97
+ // 参数装饰器
98
+ function atParameter(target: any, propertyKey: string, parameterIndex: number) {
99
+ const parameterType: any = Reflect.getMetadata("design:paramtypes", target, propertyKey);
100
+ console.log("参数装饰器,参数位置在:", parameterIndex, "参数类型是:", parameterType[parameterIndex].name);
101
+ }
102
+
103
+ // 参数装饰器,带参数
104
+ function atParameterWithArgs(...args: any[]) {
105
+ return function (target: any, propertyKey: string, parameterIndex: number) {
106
+ console.log("参数装饰器有参数,参数值:", args.join(","));
107
+ }
108
+ }
@@ -0,0 +1 @@
1
+ import("./example-import.class");
@@ -0,0 +1,25 @@
1
+ import "reflect-metadata";
2
+
3
+ class MainReflect {
4
+ @injectAge(10)
5
+ private age: number;
6
+
7
+ @findReturn
8
+ getAge(): Number {
9
+ return this.age;
10
+ }
11
+ }
12
+
13
+ const mainReflect = new MainReflect();
14
+ console.log("获得Age值:", mainReflect.getAge());
15
+
16
+ function injectAge(arg: Number) {
17
+ return function (target: any, propertyKey: string) {
18
+ Object.defineProperty(target, propertyKey, {get: () => {return arg;}});
19
+ }
20
+ }
21
+
22
+ function findReturn(target: any, propertyKey: string) {
23
+ const returnType: any = Reflect.getMetadata("design:returntype", target, propertyKey);
24
+ console.log(target[propertyKey].name, "的返回类型是:", returnType.name);
25
+ }
@@ -0,0 +1,39 @@
1
+ import { createServer, Server, IncomingMessage, ServerResponse } from "http";
2
+ import { createConnection, Connection } from "mysql2";
3
+
4
+ interface Page {
5
+ page(response: ServerResponse): void;
6
+ }
7
+
8
+ class First implements Page {
9
+ page(response: ServerResponse): void {
10
+ response.end("I am first page.");
11
+ }
12
+ }
13
+
14
+ class User implements Page {
15
+ page(response: ServerResponse): void {
16
+ const connection: Connection = createConnection({ host: 'localhost', user: 'root', "password": "qwer1234", database: 'test' });
17
+ connection.query('SELECT * FROM `user`', (err, results) => {
18
+ response.end(JSON.stringify(results));
19
+ });
20
+ }
21
+ }
22
+
23
+ class Root implements Page {
24
+ page(response: ServerResponse): void {
25
+ response.end("I am main page.");
26
+ }
27
+ }
28
+
29
+ const router = new Map<string, Page>();
30
+ router.set("/first", new First());
31
+ router.set("/main", new Root());
32
+ router.set("/user", new User());
33
+ const server = createServer((request: IncomingMessage, response: ServerResponse) => {
34
+ let page = router.get(request.url === undefined ? "" : request.url);
35
+ if (page === undefined) {
36
+ page = new Root();
37
+ }
38
+ page.page(response);
39
+ }).listen(3000);
@@ -0,0 +1,59 @@
1
+ import { createServer, Server, IncomingMessage, ServerResponse } from "http";
2
+ import { createConnection, Connection } from "mysql2";
3
+
4
+ interface Page {
5
+ page(response: ServerResponse): void;
6
+ }
7
+
8
+ class First implements Page {
9
+ page(response: ServerResponse): void {
10
+ response.end("I am first page.");
11
+ }
12
+ }
13
+
14
+ class User implements Page {
15
+ page(response: ServerResponse): void {
16
+ const database: Database = Database.getInstance();
17
+ const databaseCopy: Database = Database.getInstance();
18
+ console.log("两个对象是否一致:", database === databaseCopy)
19
+ database.query('SELECT * FROM `user`', (err, results) => {
20
+ response.end(JSON.stringify(results));
21
+ });
22
+ }
23
+ }
24
+
25
+ class Root implements Page {
26
+ page(response: ServerResponse): void {
27
+ response.end("I am main page.");
28
+ }
29
+ }
30
+
31
+ class Database {
32
+ private static instance: Database;
33
+ private connection: Connection;
34
+ private constructor(connection: Connection) {
35
+ this.connection = connection;
36
+ }
37
+ static getInstance() {
38
+ if (!Database.instance) {
39
+ Database.instance = new Database(createConnection({ host: 'localhost', user: 'root', "password": "qwer1234", database: 'test' }));
40
+ }
41
+ return Database.instance;
42
+ }
43
+ query(sql: string, callback: (err: any, results: any) => void): void {
44
+ this.connection.query('SELECT * FROM `user`', callback);
45
+ }
46
+ }
47
+
48
+
49
+ const router = new Map<string, Page>();
50
+ router.set("/first", new First());
51
+ router.set("/main", new Root());
52
+ router.set("/user", new User());
53
+ const server = createServer((request: IncomingMessage, response: ServerResponse) => {
54
+ let page = router.get(request.url === undefined ? "" : request.url);
55
+ if (page === undefined) {
56
+ page = new Root();
57
+ }
58
+ page.page(response);
59
+ }).listen(3000);
@@ -0,0 +1,10 @@
1
+ import { createServer, Server, IncomingMessage, ServerResponse } from "http";
2
+
3
+ // 使用 IF 语句来判断请求的 URL
4
+ const server = createServer((request: IncomingMessage, response: ServerResponse) => {
5
+ if (request.url === "/first") {
6
+ response.end("I am first page.");
7
+ } else {
8
+ response.end("I am main page.");
9
+ }
10
+ }).listen(3000);
@@ -0,0 +1,6 @@
1
+ import {createServer, Server, IncomingMessage, ServerResponse} from "http";
2
+
3
+ // 简单的 HTTP 服务
4
+ const server = createServer((request: IncomingMessage, response: ServerResponse) => {
5
+ response.end("Hello World");
6
+ }).listen(3000);
@@ -0,0 +1,28 @@
1
+ import { createServer, Server, IncomingMessage, ServerResponse } from "http";
2
+
3
+ interface Page {
4
+ page(response: ServerResponse): void;
5
+ }
6
+
7
+ class First implements Page {
8
+ page(response: ServerResponse): void {
9
+ response.end("I am first page.");
10
+ }
11
+ }
12
+
13
+ class Root implements Page {
14
+ page(response: ServerResponse): void {
15
+ response.end("I am main page.");
16
+ }
17
+ }
18
+
19
+ const router = new Map<string, Page>();
20
+ router.set("/first", new First());
21
+ router.set("/main", new Root());
22
+ const server = createServer((request: IncomingMessage, response: ServerResponse) => {
23
+ let page = router.get(request.url === undefined ? "" : request.url);
24
+ if (page === undefined) {
25
+ page = new Root();
26
+ }
27
+ page.page(response);
28
+ }).listen(3000);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typespeed",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "description": "A new Framework for TypeScript.",
5
5
  "author": "speedphp",
6
6
  "license": "MIT License",
@@ -8,7 +8,7 @@
8
8
  "build": "tsc -p .",
9
9
  "postbuild": "cp -r src/default/pages dist/default/pages && cp -r src/scaffold/templates dist/scaffold/templates",
10
10
  "prebuild": "rm -rf dist",
11
- "prepare": "npm version patch && npm run build",
11
+ "prepublishOnly": "npm version patch && npm run build",
12
12
  "upgrade": "npm version minor",
13
13
  "postpublish": "git push && git push --tags"
14
14
  },
@@ -23,7 +23,7 @@ if (fs.existsSync(configFile)) {
23
23
  }
24
24
 
25
25
  function app<T extends { new(...args: any[]): {} }>(constructor: T) {
26
- const coreFiles = walkSync(coreDir, { globs: ['**/*.ts'] });
26
+ const coreFiles = walkSync(coreDir, { globs: ['**/*.ts'], ignore: ['**/*.d.ts', 'scaffold/**'] });
27
27
  const mainFiles = walkSync(mainPath, { globs: ['**/*.ts'] });
28
28
 
29
29
  (async function () {
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "test-typespeed",
3
+ "version": "1.0.0",
4
+ "lockfileVersion": 2,
5
+ "requires": true,
6
+ "packages": {
7
+ "node_modules/@types/node": {
8
+ "version": "18.16.8",
9
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.16.8.tgz",
10
+ "integrity": "sha512-p0iAXcfWCOTCBbsExHIDFCfwsqFwBTgETJveKMT+Ci3LY9YqQCI91F5S+TB20+aRCXpcWfvx5Qr5EccnwCm2NA=="
11
+ },
12
+ "node_modules/colors": {
13
+ "version": "1.4.0",
14
+ "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz",
15
+ "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==",
16
+ "engines": {
17
+ "node": ">=0.1.90"
18
+ }
19
+ },
20
+ "node_modules/dateformat": {
21
+ "version": "4.5.1",
22
+ "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-4.5.1.tgz",
23
+ "integrity": "sha512-OD0TZ+B7yP7ZgpJf5K2DIbj3FZvFvxgFUuaqA/V5zTjAtAAXZ1E8bktHxmAGs4x5b7PflqA9LeQ84Og7wYtF7Q==",
24
+ "engines": {
25
+ "node": "*"
26
+ }
27
+ },
28
+ "node_modules/mkdirp": {
29
+ "version": "1.0.4",
30
+ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
31
+ "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
32
+ "bin": {
33
+ "mkdirp": "bin/cmd.js"
34
+ },
35
+ "engines": {
36
+ "node": ">=10"
37
+ }
38
+ },
39
+ "node_modules/tinytim": {
40
+ "version": "0.1.1",
41
+ "resolved": "https://registry.npmjs.org/tinytim/-/tinytim-0.1.1.tgz",
42
+ "integrity": "sha512-NIpsp9lBIxPNzB++HnMmUd4byzJSVbbO4F+As1Gb1IG/YQT5QvmBDjpx8SpDS8fhGC+t+Qw8ldQgbcAIaU+2cA==",
43
+ "engines": {
44
+ "node": ">= 0.2.0"
45
+ }
46
+ },
47
+ "node_modules/tracer": {
48
+ "version": "1.1.6",
49
+ "resolved": "https://registry.npmjs.org/tracer/-/tracer-1.1.6.tgz",
50
+ "integrity": "sha512-VKEIQRNgzSgti18whs+8l7e2y/gWcklw+C/xZtFH/AGvaN6GDlvhkQTFEsy448Gxb5MtbNbzJiG0L1TJEQnqcA==",
51
+ "dependencies": {
52
+ "colors": "1.4.0",
53
+ "dateformat": "4.5.1",
54
+ "mkdirp": "^1.0.4",
55
+ "tinytim": "0.1.1"
56
+ },
57
+ "engines": {
58
+ "node": ">= 0.10.0"
59
+ }
60
+ }
61
+ }
62
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE
@@ -0,0 +1,16 @@
1
+ # Installation
2
+ > `npm install --save @types/node`
3
+
4
+ # Summary
5
+ This package contains type definitions for Node.js (https://nodejs.org/).
6
+
7
+ # Details
8
+ Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node/v18.
9
+
10
+ ### Additional Details
11
+ * Last updated: Thu, 11 May 2023 20:02:57 GMT
12
+ * Dependencies: none
13
+ * Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`, `structuredClone`
14
+
15
+ # Credits
16
+ These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [DefinitelyTyped](https://github.com/DefinitelyTyped), [Alberto Schiabel](https://github.com/jkomyno), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Chigozirim C.](https://github.com/smac89), [David Junger](https://github.com/touffy), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [Huw](https://github.com/hoo29), [Kelvin Jin](https://github.com/kjin), [Klaus Meinhardt](https://github.com/ajafff), [Lishude](https://github.com/islishude), [Mariusz Wiktorczyk](https://github.com/mwiktorczyk), [Mohsen Azimi](https://github.com/mohsen1), [Nicolas Even](https://github.com/n-e), [Nikita Galkin](https://github.com/galkin), [Parambir Singh](https://github.com/parambirs), [Sebastian Silbermann](https://github.com/eps1lon), [Simon Schick](https://github.com/SimonSchick), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Thanik Bhongbhibhat](https://github.com/bhongy), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Victor Perin](https://github.com/victorperin), [Yongsheng Zhang](https://github.com/ZYSzys), [NodeJS Contributors](https://github.com/NodeJS), [Linus Unnebäck](https://github.com/LinusU), [wafuwafu13](https://github.com/wafuwafu13), [Matteo Collina](https://github.com/mcollina), and [Dmitry Semigradsky](https://github.com/Semigradsky).
@@ -0,0 +1,8 @@
1
+ declare module 'assert/strict' {
2
+ import { strict } from 'node:assert';
3
+ export = strict;
4
+ }
5
+ declare module 'node:assert/strict' {
6
+ import { strict } from 'node:assert';
7
+ export = strict;
8
+ }