@fastcar/koa 0.1.12 → 0.1.14
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/index.d.ts +3 -0
- package/package.json +9 -9
- package/src/annotation.ts +0 -2
- package/src/index.ts +2 -2
- package/src/middleware/ExceptionGlobalHandler.ts +1 -1
- package/src/middleware/KoaBody.ts +3 -2
- package/src/middleware/KoaBodyParser.ts +2 -1
- package/src/middleware/KoaCors.ts +3 -2
- package/src/middleware/KoaMulter.ts +2 -1
- package/src/middleware/KoaStatic.ts +5 -3
- package/src/type/KoaConfig.ts +2 -5
- package/target/KoaApplication.js +147 -143
- package/target/annotation/EnableKoa.js +11 -11
- package/target/annotation/KoaMiddleware.js +19 -19
- package/target/annotation/router/AddMapping.js +29 -29
- package/target/annotation/router/AllMapping.js +14 -14
- package/target/annotation/router/DeleteMapping.js +14 -14
- package/target/annotation/router/GetMapping.js +14 -14
- package/target/annotation/router/PatchMapping.js +14 -14
- package/target/annotation/router/PostMapping.js +14 -14
- package/target/annotation/router/PutMapping.js +14 -14
- package/target/annotation/router/RequestMapping.js +22 -22
- package/target/annotation.js +38 -40
- package/target/index.js +19 -19
- package/target/middleware/ExceptionGlobalHandler.js +32 -32
- package/target/middleware/KoaBody.js +10 -10
- package/target/middleware/KoaBodyParser.js +10 -10
- package/target/middleware/KoaCors.js +33 -33
- package/target/middleware/KoaMulter.js +8 -8
- package/target/middleware/KoaStatic.js +38 -38
- package/target/type/DesignMeta.js +7 -7
- package/target/type/KoaConfig.js +2 -2
- package/target/type/MethodType.js +2 -2
- package/target/type/RouteMethods.js +12 -12
- package/test/logs/sys.log +78 -118
- package/test/simple/app.ts +4 -5
- package/src/middleware/Swagger.ts +0 -63
- package/target/middleware/Swagger.js +0 -53
- package/target/npmlist.json +0 -1
- package/test/logs/koa.log +0 -0
- package/test/logs/serverlogger.log +0 -3
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RouteMethods = void 0;
|
|
4
|
-
var RouteMethods;
|
|
5
|
-
(function (RouteMethods) {
|
|
6
|
-
RouteMethods["GetMapping"] = "get";
|
|
7
|
-
RouteMethods["PostMapping"] = "post";
|
|
8
|
-
RouteMethods["PutMapping"] = "put";
|
|
9
|
-
RouteMethods["DeleteMapping"] = "delete";
|
|
10
|
-
RouteMethods["PatchMapping"] = "patch";
|
|
11
|
-
RouteMethods["AllMapping"] = "all";
|
|
12
|
-
})(RouteMethods
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RouteMethods = void 0;
|
|
4
|
+
var RouteMethods;
|
|
5
|
+
(function (RouteMethods) {
|
|
6
|
+
RouteMethods["GetMapping"] = "get";
|
|
7
|
+
RouteMethods["PostMapping"] = "post";
|
|
8
|
+
RouteMethods["PutMapping"] = "put";
|
|
9
|
+
RouteMethods["DeleteMapping"] = "delete";
|
|
10
|
+
RouteMethods["PatchMapping"] = "patch";
|
|
11
|
+
RouteMethods["AllMapping"] = "all";
|
|
12
|
+
})(RouteMethods || (exports.RouteMethods = RouteMethods = {}));
|
package/test/logs/sys.log
CHANGED
|
@@ -1,118 +1,78 @@
|
|
|
1
|
-
{"timestamp":"
|
|
2
|
-
{"timestamp":"
|
|
3
|
-
{"timestamp":"
|
|
4
|
-
{"timestamp":"
|
|
5
|
-
{"timestamp":"
|
|
6
|
-
{"timestamp":"
|
|
7
|
-
{"timestamp":"
|
|
8
|
-
{"timestamp":"
|
|
9
|
-
{"timestamp":"
|
|
10
|
-
{"timestamp":"
|
|
11
|
-
{"timestamp":"
|
|
12
|
-
{"timestamp":"
|
|
13
|
-
{"timestamp":"
|
|
14
|
-
{"timestamp":"
|
|
15
|
-
{"timestamp":"
|
|
16
|
-
{"timestamp":"
|
|
17
|
-
{"timestamp":"
|
|
18
|
-
{"timestamp":"
|
|
19
|
-
{"timestamp":"
|
|
20
|
-
{"timestamp":"
|
|
21
|
-
{"timestamp":"
|
|
22
|
-
{"timestamp":"
|
|
23
|
-
{"timestamp":"
|
|
24
|
-
{"timestamp":"
|
|
25
|
-
{"timestamp":"
|
|
26
|
-
{"timestamp":"
|
|
27
|
-
{"timestamp":"
|
|
28
|
-
{"timestamp":"
|
|
29
|
-
{"timestamp":"
|
|
30
|
-
{"timestamp":"
|
|
31
|
-
{"timestamp":"
|
|
32
|
-
{"timestamp":"
|
|
33
|
-
{"timestamp":"
|
|
34
|
-
{"timestamp":"
|
|
35
|
-
{"timestamp":"
|
|
36
|
-
{"timestamp":"
|
|
37
|
-
{"timestamp":"
|
|
38
|
-
{"timestamp":"
|
|
39
|
-
{"timestamp":"
|
|
40
|
-
{"timestamp":"
|
|
41
|
-
{"timestamp":"
|
|
42
|
-
{"timestamp":"
|
|
43
|
-
{"timestamp":"
|
|
44
|
-
{"timestamp":"
|
|
45
|
-
{"timestamp":"
|
|
46
|
-
{"timestamp":"
|
|
47
|
-
{"timestamp":"
|
|
48
|
-
{"timestamp":"
|
|
49
|
-
{"timestamp":"
|
|
50
|
-
{"timestamp":"
|
|
51
|
-
{"timestamp":"
|
|
52
|
-
{"timestamp":"
|
|
53
|
-
{"timestamp":"
|
|
54
|
-
{"timestamp":"
|
|
55
|
-
{"timestamp":"
|
|
56
|
-
{"timestamp":"
|
|
57
|
-
{"timestamp":"
|
|
58
|
-
{"timestamp":"
|
|
59
|
-
{"timestamp":"
|
|
60
|
-
{"timestamp":"
|
|
61
|
-
{"timestamp":"
|
|
62
|
-
{"timestamp":"
|
|
63
|
-
{"timestamp":"
|
|
64
|
-
{"timestamp":"
|
|
65
|
-
{"timestamp":"
|
|
66
|
-
{"timestamp":"
|
|
67
|
-
{"timestamp":"
|
|
68
|
-
{"timestamp":"
|
|
69
|
-
{"timestamp":"
|
|
70
|
-
{"timestamp":"
|
|
71
|
-
{"timestamp":"
|
|
72
|
-
{"timestamp":"
|
|
73
|
-
{"timestamp":"
|
|
74
|
-
{"timestamp":"
|
|
75
|
-
{"timestamp":"
|
|
76
|
-
{"timestamp":"
|
|
77
|
-
{"timestamp":"
|
|
78
|
-
{"timestamp":"
|
|
79
|
-
{"timestamp":"2023-11-06 11:03:09.602","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
80
|
-
{"timestamp":"2023-11-06 11:03:10.19","level":"INFO","label":"sys","message":"http server is running in 1234"}
|
|
81
|
-
{"timestamp":"2023-11-06 11:03:10.19","level":"INFO","label":"sys","message":"start server koaSimple is run"}
|
|
82
|
-
{"timestamp":"2023-11-06 11:03:10.20","level":"INFO","label":"sys","message":"version 1.0.0"}
|
|
83
|
-
{"timestamp":"2023-11-06 11:04:45.703","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
84
|
-
{"timestamp":"2023-11-06 11:04:46.665","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
85
|
-
{"timestamp":"2023-11-06 11:04:46.665","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
86
|
-
{"timestamp":"2023-11-06 11:04:46.672","level":"INFO","label":"sys","message":"http server is running in 1234"}
|
|
87
|
-
{"timestamp":"2023-11-06 11:04:46.672","level":"INFO","label":"sys","message":"start server koaSimple is run"}
|
|
88
|
-
{"timestamp":"2023-11-06 11:04:46.673","level":"INFO","label":"sys","message":"version 1.0.0"}
|
|
89
|
-
{"timestamp":"2023-11-06 11:06:22.126","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
90
|
-
{"timestamp":"2023-11-06 11:06:22.428","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
91
|
-
{"timestamp":"2023-11-06 11:06:22.428","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
92
|
-
{"timestamp":"2023-11-06 11:06:30.951","level":"INFO","label":"sys","message":"http server is running in 1234"}
|
|
93
|
-
{"timestamp":"2023-11-06 11:06:30.952","level":"INFO","label":"sys","message":"start server koaSimple is run"}
|
|
94
|
-
{"timestamp":"2023-11-06 11:06:30.953","level":"INFO","label":"sys","message":"version 1.0.0"}
|
|
95
|
-
{"timestamp":"2023-11-06 11:06:37.815","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
96
|
-
{"timestamp":"2023-11-06 11:06:38.123","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
97
|
-
{"timestamp":"2023-11-06 11:06:38.124","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
98
|
-
{"timestamp":"2023-11-06 11:06:40.295","level":"INFO","label":"sys","message":"http server is running in 1234"}
|
|
99
|
-
{"timestamp":"2023-11-06 11:06:40.296","level":"INFO","label":"sys","message":"start server koaSimple is run"}
|
|
100
|
-
{"timestamp":"2023-11-06 11:06:40.296","level":"INFO","label":"sys","message":"version 1.0.0"}
|
|
101
|
-
{"timestamp":"2023-11-06 11:19:08.992","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
102
|
-
{"timestamp":"2023-11-06 11:19:09.815","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
103
|
-
{"timestamp":"2023-11-06 11:19:09.816","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
104
|
-
{"timestamp":"2023-11-06 11:19:13.80","level":"INFO","label":"sys","message":"http server is running in 1234"}
|
|
105
|
-
{"timestamp":"2023-11-06 11:19:13.81","level":"INFO","label":"sys","message":"start server koaSimple is run"}
|
|
106
|
-
{"timestamp":"2023-11-06 11:19:13.81","level":"INFO","label":"sys","message":"version 1.0.0"}
|
|
107
|
-
{"timestamp":"2023-11-06 11:33:57.571","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
108
|
-
{"timestamp":"2023-11-06 11:33:57.951","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
109
|
-
{"timestamp":"2023-11-06 11:33:57.951","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
110
|
-
{"timestamp":"2023-11-06 11:33:57.958","level":"INFO","label":"sys","message":"http server is running in 1234"}
|
|
111
|
-
{"timestamp":"2023-11-06 11:33:57.959","level":"INFO","label":"sys","message":"start server koaSimple is run"}
|
|
112
|
-
{"timestamp":"2023-11-06 11:33:57.959","level":"INFO","label":"sys","message":"version 1.0.0"}
|
|
113
|
-
{"timestamp":"2023-11-06 11:38:42.619","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
114
|
-
{"timestamp":"2023-11-06 11:38:42.903","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
115
|
-
{"timestamp":"2023-11-06 11:38:42.904","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
116
|
-
{"timestamp":"2023-11-06 11:38:42.910","level":"INFO","label":"sys","message":"http server is running in 1234"}
|
|
117
|
-
{"timestamp":"2023-11-06 11:38:42.911","level":"INFO","label":"sys","message":"start server koaSimple is run"}
|
|
118
|
-
{"timestamp":"2023-11-06 11:38:42.912","level":"INFO","label":"sys","message":"version 1.0.0"}
|
|
1
|
+
{"timestamp":"2024-12-05 10:44:45.957","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
2
|
+
{"timestamp":"2024-12-05 10:44:48.179","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
3
|
+
{"timestamp":"2024-12-05 10:44:48.181","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
4
|
+
{"timestamp":"2024-12-05 10:44:49.496","level":"ERROR","label":"sys","message":"Unhandled Rejection at:","splat":"[{}]"}
|
|
5
|
+
{"timestamp":"2024-12-05 10:44:49.519","level":"ERROR","label":"sys","message":"reason: bodyParser is not a function","splat":"[{}]","stack":"TypeError: bodyParser is not a function\n at KoaApplication.KoaBodyParser (D:\\code\\fast-car\\fastcar-koa\\src\\middleware\\KoaBodyParser.ts:11:9)\n at KoaApplication.start (D:\\code\\fast-car\\fastcar-koa\\src\\KoaApplication.ts:119:63)\n at FastCarApplication.automaticRun (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\FastCarApplication.js:632:25)\n at FastCarApplication.startServer (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\FastCarApplication.js:658:20)\n at FastCarApplication.init (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\FastCarApplication.js:565:14)\n at Object.construct (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\annotation\\Application.js:42:17)\n at Object.<anonymous> (D:\\code\\fast-car\\fastcar-koa\\test\\simple\\app.ts:36:20)\n at Module._compile (node:internal/modules/cjs/loader:1358:14)\n at Module.m._compile (D:\\code\\fast-car\\node_modules\\ts-node\\src\\index.ts:1618:23)\n at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)"}
|
|
6
|
+
{"timestamp":"2024-12-05 10:44:49.527","level":"INFO","label":"sys","message":"application stop"}
|
|
7
|
+
{"timestamp":"2024-12-05 10:45:33.494","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
8
|
+
{"timestamp":"2024-12-05 10:45:33.797","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
9
|
+
{"timestamp":"2024-12-05 10:45:33.798","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
10
|
+
{"timestamp":"2024-12-05 10:45:33.833","level":"ERROR","label":"sys","message":"Unhandled Rejection at:","splat":"[{}]"}
|
|
11
|
+
{"timestamp":"2024-12-05 10:45:33.838","level":"ERROR","label":"sys","message":"reason: Cannot find module '@koa/multer'\nRequire stack:\n- D:\\code\\fast-car\\fastcar-koa\\src\\middleware\\KoaMulter.ts\n- D:\\code\\fast-car\\fastcar-koa\\test\\simple\\app.ts","splat":"[{\"code\":\"MODULE_NOT_FOUND\",\"requireStack\":[\"D:\\\\code\\\\fast-car\\\\fastcar-koa\\\\src\\\\middleware\\\\KoaMulter.ts\",\"D:\\\\code\\\\fast-car\\\\fastcar-koa\\\\test\\\\simple\\\\app.ts\"]}]","stack":"Error: Cannot find module '@koa/multer'\nRequire stack:\n- D:\\code\\fast-car\\fastcar-koa\\src\\middleware\\KoaMulter.ts\n- D:\\code\\fast-car\\fastcar-koa\\test\\simple\\app.ts\n at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)\n at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (D:\\code\\fast-car\\node_modules\\@cspotcode\\source-map-support\\source-map-support.js:811:30)\n at Function.Module._load (node:internal/modules/cjs/loader:986:27)\n at Module.require (node:internal/modules/cjs/loader:1233:19)\n at require (node:internal/modules/helpers:179:18)\n at KoaApplication.KoaMulter (D:\\code\\fast-car\\fastcar-koa\\src\\middleware\\KoaMulter.ts:5:17)\n at KoaApplication.start (D:\\code\\fast-car\\fastcar-koa\\src\\KoaApplication.ts:119:63)\n at FastCarApplication.automaticRun (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\FastCarApplication.js:632:25)\n at FastCarApplication.startServer (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\FastCarApplication.js:658:20)\n at FastCarApplication.init (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\FastCarApplication.js:565:14)"}
|
|
12
|
+
{"timestamp":"2024-12-05 10:45:33.840","level":"INFO","label":"sys","message":"application stop"}
|
|
13
|
+
{"timestamp":"2024-12-05 10:54:34.486","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
14
|
+
{"timestamp":"2024-12-05 10:54:37.56","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
15
|
+
{"timestamp":"2024-12-05 10:54:37.56","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
16
|
+
{"timestamp":"2024-12-05 10:54:42.399","level":"ERROR","label":"sys","message":"Unhandled Rejection at:","splat":"[{}]"}
|
|
17
|
+
{"timestamp":"2024-12-05 10:54:42.448","level":"ERROR","label":"sys","message":"reason: Cannot find module 'multer'\nRequire stack:\n- D:\\code\\fast-car\\fastcar-koa\\node_modules\\fix-esm\\index.js\n- D:\\code\\fast-car\\fastcar-koa\\node_modules\\@koa\\multer\\index.js\n- D:\\code\\fast-car\\fastcar-koa\\src\\middleware\\KoaMulter.ts\n- D:\\code\\fast-car\\fastcar-koa\\test\\simple\\app.ts","splat":"[{\"code\":\"MODULE_NOT_FOUND\",\"requireStack\":[\"D:\\\\code\\\\fast-car\\\\fastcar-koa\\\\node_modules\\\\fix-esm\\\\index.js\",\"D:\\\\code\\\\fast-car\\\\fastcar-koa\\\\node_modules\\\\@koa\\\\multer\\\\index.js\",\"D:\\\\code\\\\fast-car\\\\fastcar-koa\\\\src\\\\middleware\\\\KoaMulter.ts\",\"D:\\\\code\\\\fast-car\\\\fastcar-koa\\\\test\\\\simple\\\\app.ts\"]}]","stack":"Error: Cannot find module 'multer'\nRequire stack:\n- D:\\code\\fast-car\\fastcar-koa\\node_modules\\fix-esm\\index.js\n- D:\\code\\fast-car\\fastcar-koa\\node_modules\\@koa\\multer\\index.js\n- D:\\code\\fast-car\\fastcar-koa\\src\\middleware\\KoaMulter.ts\n- D:\\code\\fast-car\\fastcar-koa\\test\\simple\\app.ts\n at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)\n at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (D:\\code\\fast-car\\node_modules\\@cspotcode\\source-map-support\\source-map-support.js:811:30)\n at Function.Module._load (node:internal/modules/cjs/loader:986:27)\n at Module.require (node:internal/modules/cjs/loader:1233:19)\n at require (node:internal/modules/helpers:179:18)\n at Object.require (D:\\code\\fast-car\\fastcar-koa\\node_modules\\fix-esm\\index.js:48:18)\n at Object.<anonymous> (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@koa\\multer\\index.js:14:41)\n at Module._compile (node:internal/modules/cjs/loader:1358:14)\n at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)\n at Object.require.extensions.<computed> (D:\\code\\fast-car\\node_modules\\ts-node\\src\\index.ts:1608:43)"}
|
|
18
|
+
{"timestamp":"2024-12-05 10:54:42.453","level":"INFO","label":"sys","message":"application stop"}
|
|
19
|
+
{"timestamp":"2024-12-05 10:55:10.793","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
20
|
+
{"timestamp":"2024-12-05 10:55:11.319","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
21
|
+
{"timestamp":"2024-12-05 10:55:11.320","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
22
|
+
{"timestamp":"2024-12-05 10:55:12.568","level":"ERROR","label":"sys","message":"Unhandled Rejection at:","splat":"[{}]"}
|
|
23
|
+
{"timestamp":"2024-12-05 10:55:12.577","level":"ERROR","label":"sys","message":"reason: multer is not a function","splat":"[{}]","stack":"TypeError: multer is not a function\n at KoaApplication.KoaMulter (D:\\code\\fast-car\\fastcar-koa\\src\\middleware\\KoaMulter.ts:7:9)\n at KoaApplication.start (D:\\code\\fast-car\\fastcar-koa\\src\\KoaApplication.ts:119:63)\n at FastCarApplication.automaticRun (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\FastCarApplication.js:632:25)\n at FastCarApplication.startServer (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\FastCarApplication.js:658:20)\n at FastCarApplication.init (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\FastCarApplication.js:565:14)\n at Object.construct (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\annotation\\Application.js:42:17)\n at Object.<anonymous> (D:\\code\\fast-car\\fastcar-koa\\test\\simple\\app.ts:36:20)\n at Module._compile (node:internal/modules/cjs/loader:1358:14)\n at Module.m._compile (D:\\code\\fast-car\\node_modules\\ts-node\\src\\index.ts:1618:23)\n at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)"}
|
|
24
|
+
{"timestamp":"2024-12-05 10:55:12.583","level":"INFO","label":"sys","message":"application stop"}
|
|
25
|
+
{"timestamp":"2024-12-05 10:55:32.988","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
26
|
+
{"timestamp":"2024-12-05 10:55:33.494","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
27
|
+
{"timestamp":"2024-12-05 10:55:33.496","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
28
|
+
{"timestamp":"2024-12-05 10:55:38.275","level":"INFO","label":"sys","message":"http server is running in 1234"}
|
|
29
|
+
{"timestamp":"2024-12-05 10:55:38.276","level":"INFO","label":"sys","message":"start server koaSimple is run"}
|
|
30
|
+
{"timestamp":"2024-12-05 10:55:38.277","level":"INFO","label":"sys","message":"version 1.0.0"}
|
|
31
|
+
{"timestamp":"2024-12-05 10:59:08.565","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
32
|
+
{"timestamp":"2024-12-05 10:59:08.846","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
33
|
+
{"timestamp":"2024-12-05 10:59:08.847","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
34
|
+
{"timestamp":"2024-12-05 10:59:10.483","level":"ERROR","label":"sys","message":"Unhandled Rejection at:","splat":"[{}]"}
|
|
35
|
+
{"timestamp":"2024-12-05 10:59:10.491","level":"ERROR","label":"sys","message":"reason: Cannot find module 'koa-range'\nRequire stack:\n- D:\\code\\fast-car\\fastcar-koa\\src\\middleware\\KoaStatic.ts\n- D:\\code\\fast-car\\fastcar-koa\\test\\simple\\app.ts","splat":"[{\"code\":\"MODULE_NOT_FOUND\",\"requireStack\":[\"D:\\\\code\\\\fast-car\\\\fastcar-koa\\\\src\\\\middleware\\\\KoaStatic.ts\",\"D:\\\\code\\\\fast-car\\\\fastcar-koa\\\\test\\\\simple\\\\app.ts\"]}]","stack":"Error: Cannot find module 'koa-range'\nRequire stack:\n- D:\\code\\fast-car\\fastcar-koa\\src\\middleware\\KoaStatic.ts\n- D:\\code\\fast-car\\fastcar-koa\\test\\simple\\app.ts\n at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)\n at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (D:\\code\\fast-car\\node_modules\\@cspotcode\\source-map-support\\source-map-support.js:811:30)\n at Function.Module._load (node:internal/modules/cjs/loader:986:27)\n at Module.require (node:internal/modules/cjs/loader:1233:19)\n at require (node:internal/modules/helpers:179:18)\n at KoaApplication.KoaStatic (D:\\code\\fast-car\\fastcar-koa\\src\\middleware\\KoaStatic.ts:9:19)\n at KoaApplication.start (D:\\code\\fast-car\\fastcar-koa\\src\\KoaApplication.ts:119:63)\n at FastCarApplication.automaticRun (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\FastCarApplication.js:632:25)\n at FastCarApplication.startServer (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\FastCarApplication.js:658:20)\n at FastCarApplication.init (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\FastCarApplication.js:565:14)"}
|
|
36
|
+
{"timestamp":"2024-12-05 10:59:10.494","level":"INFO","label":"sys","message":"application stop"}
|
|
37
|
+
{"timestamp":"2024-12-05 10:59:27.934","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
38
|
+
{"timestamp":"2024-12-05 10:59:28.242","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
39
|
+
{"timestamp":"2024-12-05 10:59:28.243","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
40
|
+
{"timestamp":"2024-12-05 10:59:28.533","level":"ERROR","label":"sys","message":"Unhandled Rejection at:","splat":"[{}]"}
|
|
41
|
+
{"timestamp":"2024-12-05 10:59:28.538","level":"ERROR","label":"sys","message":"reason: Cannot find module 'koa-body'\nRequire stack:\n- D:\\code\\fast-car\\fastcar-koa\\src\\middleware\\KoaBody.ts\n- D:\\code\\fast-car\\fastcar-koa\\test\\simple\\app.ts","splat":"[{\"code\":\"MODULE_NOT_FOUND\",\"requireStack\":[\"D:\\\\code\\\\fast-car\\\\fastcar-koa\\\\src\\\\middleware\\\\KoaBody.ts\",\"D:\\\\code\\\\fast-car\\\\fastcar-koa\\\\test\\\\simple\\\\app.ts\"]}]","stack":"Error: Cannot find module 'koa-body'\nRequire stack:\n- D:\\code\\fast-car\\fastcar-koa\\src\\middleware\\KoaBody.ts\n- D:\\code\\fast-car\\fastcar-koa\\test\\simple\\app.ts\n at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)\n at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (D:\\code\\fast-car\\node_modules\\@cspotcode\\source-map-support\\source-map-support.js:811:30)\n at Function.Module._load (node:internal/modules/cjs/loader:986:27)\n at Module.require (node:internal/modules/cjs/loader:1233:19)\n at require (node:internal/modules/helpers:179:18)\n at KoaApplication.KoaBody (D:\\code\\fast-car\\fastcar-koa\\src\\middleware\\KoaBody.ts:6:20)\n at KoaApplication.start (D:\\code\\fast-car\\fastcar-koa\\src\\KoaApplication.ts:119:63)\n at FastCarApplication.automaticRun (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\FastCarApplication.js:632:25)\n at FastCarApplication.startServer (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\FastCarApplication.js:658:20)\n at FastCarApplication.init (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\FastCarApplication.js:565:14)"}
|
|
42
|
+
{"timestamp":"2024-12-05 10:59:28.542","level":"INFO","label":"sys","message":"application stop"}
|
|
43
|
+
{"timestamp":"2024-12-05 10:59:45.73","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
44
|
+
{"timestamp":"2024-12-05 10:59:45.536","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
45
|
+
{"timestamp":"2024-12-05 10:59:45.537","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
46
|
+
{"timestamp":"2024-12-05 10:59:46.682","level":"ERROR","label":"sys","message":"Unhandled Rejection at:","splat":"[{}]"}
|
|
47
|
+
{"timestamp":"2024-12-05 10:59:46.690","level":"ERROR","label":"sys","message":"reason: koaBodyfn is not a function","splat":"[{}]","stack":"TypeError: koaBodyfn is not a function\n at KoaApplication.KoaBody (D:\\code\\fast-car\\fastcar-koa\\src\\middleware\\KoaBody.ts:11:9)\n at KoaApplication.start (D:\\code\\fast-car\\fastcar-koa\\src\\KoaApplication.ts:119:63)\n at FastCarApplication.automaticRun (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\FastCarApplication.js:632:25)\n at FastCarApplication.startServer (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\FastCarApplication.js:658:20)\n at FastCarApplication.init (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\FastCarApplication.js:565:14)\n at Object.construct (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\annotation\\Application.js:42:17)\n at Object.<anonymous> (D:\\code\\fast-car\\fastcar-koa\\test\\simple\\app.ts:37:20)\n at Module._compile (node:internal/modules/cjs/loader:1358:14)\n at Module.m._compile (D:\\code\\fast-car\\node_modules\\ts-node\\src\\index.ts:1618:23)\n at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)"}
|
|
48
|
+
{"timestamp":"2024-12-05 10:59:46.697","level":"INFO","label":"sys","message":"application stop"}
|
|
49
|
+
{"timestamp":"2024-12-05 11:00:08.585","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
50
|
+
{"timestamp":"2024-12-05 11:00:08.893","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
51
|
+
{"timestamp":"2024-12-05 11:00:08.894","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
52
|
+
{"timestamp":"2024-12-05 11:00:09.682","level":"ERROR","label":"sys","message":"Unhandled Rejection at:","splat":"[{}]"}
|
|
53
|
+
{"timestamp":"2024-12-05 11:00:09.691","level":"ERROR","label":"sys","message":"reason: Cannot find module 'koa2-cors'\nRequire stack:\n- D:\\code\\fast-car\\fastcar-koa\\src\\middleware\\koaCors.ts\n- D:\\code\\fast-car\\fastcar-koa\\test\\simple\\app.ts","splat":"[{\"code\":\"MODULE_NOT_FOUND\",\"requireStack\":[\"D:\\\\code\\\\fast-car\\\\fastcar-koa\\\\src\\\\middleware\\\\koaCors.ts\",\"D:\\\\code\\\\fast-car\\\\fastcar-koa\\\\test\\\\simple\\\\app.ts\"]}]","stack":"Error: Cannot find module 'koa2-cors'\nRequire stack:\n- D:\\code\\fast-car\\fastcar-koa\\src\\middleware\\koaCors.ts\n- D:\\code\\fast-car\\fastcar-koa\\test\\simple\\app.ts\n at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)\n at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (D:\\code\\fast-car\\node_modules\\@cspotcode\\source-map-support\\source-map-support.js:811:30)\n at Function.Module._load (node:internal/modules/cjs/loader:986:27)\n at Module.require (node:internal/modules/cjs/loader:1233:19)\n at require (node:internal/modules/helpers:179:18)\n at KoaApplication.KoaCors (D:\\code\\fast-car\\fastcar-koa\\src\\middleware\\koaCors.ts:6:19)\n at KoaApplication.start (D:\\code\\fast-car\\fastcar-koa\\src\\KoaApplication.ts:119:63)\n at FastCarApplication.automaticRun (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\FastCarApplication.js:632:25)\n at FastCarApplication.startServer (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\FastCarApplication.js:658:20)\n at FastCarApplication.init (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\FastCarApplication.js:565:14)"}
|
|
54
|
+
{"timestamp":"2024-12-05 11:00:09.697","level":"INFO","label":"sys","message":"application stop"}
|
|
55
|
+
{"timestamp":"2024-12-05 11:00:29.09","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
56
|
+
{"timestamp":"2024-12-05 11:00:29.301","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
57
|
+
{"timestamp":"2024-12-05 11:00:29.301","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
58
|
+
{"timestamp":"2024-12-05 11:00:31.418","level":"INFO","label":"sys","message":"http server is running in 1234"}
|
|
59
|
+
{"timestamp":"2024-12-05 11:00:31.419","level":"INFO","label":"sys","message":"start server koaSimple is run"}
|
|
60
|
+
{"timestamp":"2024-12-05 11:00:31.420","level":"INFO","label":"sys","message":"version 1.0.0"}
|
|
61
|
+
{"timestamp":"2024-12-05 11:00:40.53","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
62
|
+
{"timestamp":"2024-12-05 11:00:40.494","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
63
|
+
{"timestamp":"2024-12-05 11:00:40.495","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
64
|
+
{"timestamp":"2024-12-05 11:00:47.246","level":"INFO","label":"sys","message":"http server is running in 1234"}
|
|
65
|
+
{"timestamp":"2024-12-05 11:00:47.247","level":"INFO","label":"sys","message":"start server koaSimple is run"}
|
|
66
|
+
{"timestamp":"2024-12-05 11:00:47.248","level":"INFO","label":"sys","message":"version 1.0.0"}
|
|
67
|
+
{"timestamp":"2024-12-05 11:09:53.260","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
68
|
+
{"timestamp":"2024-12-05 11:09:53.791","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
69
|
+
{"timestamp":"2024-12-05 11:09:53.793","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
70
|
+
{"timestamp":"2024-12-05 11:09:53.889","level":"ERROR","label":"sys","message":"Unhandled Rejection at:","splat":"[{}]"}
|
|
71
|
+
{"timestamp":"2024-12-05 11:09:53.898","level":"ERROR","label":"sys","message":"reason: Cannot find module '@koa/multer'\nRequire stack:\n- D:\\code\\fast-car\\fastcar-koa\\src\\middleware\\KoaMulter.ts\n- D:\\code\\fast-car\\fastcar-koa\\test\\simple\\app.ts","splat":"[{\"code\":\"MODULE_NOT_FOUND\",\"requireStack\":[\"D:\\\\code\\\\fast-car\\\\fastcar-koa\\\\src\\\\middleware\\\\KoaMulter.ts\",\"D:\\\\code\\\\fast-car\\\\fastcar-koa\\\\test\\\\simple\\\\app.ts\"]}]","stack":"Error: Cannot find module '@koa/multer'\nRequire stack:\n- D:\\code\\fast-car\\fastcar-koa\\src\\middleware\\KoaMulter.ts\n- D:\\code\\fast-car\\fastcar-koa\\test\\simple\\app.ts\n at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)\n at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (D:\\code\\fast-car\\node_modules\\@cspotcode\\source-map-support\\source-map-support.js:811:30)\n at Function.Module._load (node:internal/modules/cjs/loader:986:27)\n at Module.require (node:internal/modules/cjs/loader:1233:19)\n at require (node:internal/modules/helpers:179:18)\n at KoaApplication.KoaMulter (D:\\code\\fast-car\\fastcar-koa\\src\\middleware\\KoaMulter.ts:5:17)\n at KoaApplication.start (D:\\code\\fast-car\\fastcar-koa\\src\\KoaApplication.ts:119:63)\n at FastCarApplication.automaticRun (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\FastCarApplication.js:632:25)\n at FastCarApplication.startServer (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\FastCarApplication.js:658:20)\n at FastCarApplication.init (D:\\code\\fast-car\\fastcar-koa\\node_modules\\@fastcar\\core\\target\\FastCarApplication.js:565:14)"}
|
|
72
|
+
{"timestamp":"2024-12-05 11:09:53.907","level":"INFO","label":"sys","message":"application stop"}
|
|
73
|
+
{"timestamp":"2024-12-05 11:10:31.976","level":"INFO","label":"sys","message":"Start scanning component"}
|
|
74
|
+
{"timestamp":"2024-12-05 11:10:32.278","level":"INFO","label":"sys","message":"Complete component scan"}
|
|
75
|
+
{"timestamp":"2024-12-05 11:10:32.279","level":"INFO","label":"sys","message":"Call application initialization method"}
|
|
76
|
+
{"timestamp":"2024-12-05 11:10:32.316","level":"INFO","label":"sys","message":"http server is running in 1234"}
|
|
77
|
+
{"timestamp":"2024-12-05 11:10:32.317","level":"INFO","label":"sys","message":"start server koaSimple is run"}
|
|
78
|
+
{"timestamp":"2024-12-05 11:10:32.317","level":"INFO","label":"sys","message":"version 1.0.0"}
|
package/test/simple/app.ts
CHANGED
|
@@ -2,13 +2,12 @@ import { FastCarApplication } from "@fastcar/core";
|
|
|
2
2
|
import { Application } from "@fastcar/core/annotation";
|
|
3
3
|
import EnableKoa from "../../src/annotation/EnableKoa";
|
|
4
4
|
import KoaMiddleware from "../../src/annotation/KoaMiddleware";
|
|
5
|
-
import KoaStatic from "../../src/middleware/KoaStatic";
|
|
5
|
+
// import KoaStatic from "../../src/middleware/KoaStatic";
|
|
6
6
|
import KoaBodyParser from "../../src/middleware/KoaBodyParser";
|
|
7
7
|
import * as Koa from "koa";
|
|
8
8
|
import ExceptionGlobalHandler from "../../src/middleware/ExceptionGlobalHandler";
|
|
9
|
-
import KoaCors from "../../src/middleware/koaCors";
|
|
10
|
-
import
|
|
11
|
-
import KoaMulter from "../../src/middleware/KoaMulter";
|
|
9
|
+
// import KoaCors from "../../src/middleware/koaCors";
|
|
10
|
+
// import KoaMulter from "../../src/middleware/KoaMulter";
|
|
12
11
|
|
|
13
12
|
const m1 = () => {
|
|
14
13
|
return async (ctx: any, next: Function) => {
|
|
@@ -28,7 +27,7 @@ const m2 = (): Koa.Middleware => {
|
|
|
28
27
|
|
|
29
28
|
@Application
|
|
30
29
|
@EnableKoa //开启koa
|
|
31
|
-
@KoaMiddleware(ExceptionGlobalHandler, KoaBodyParser
|
|
30
|
+
@KoaMiddleware(ExceptionGlobalHandler, KoaBodyParser)
|
|
32
31
|
// @KoaMiddleware(m1, m2)
|
|
33
32
|
class APP {
|
|
34
33
|
app!: FastCarApplication;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { Context, Middleware, Next } from "koa";
|
|
2
|
-
import * as fs from "fs";
|
|
3
|
-
import * as path from "path";
|
|
4
|
-
import { FastCarApplication } from "@fastcar/core";
|
|
5
|
-
import { KoaConfig } from "../type/KoaConfig";
|
|
6
|
-
import * as koaStatic from "koa-static";
|
|
7
|
-
import * as KoaMount from "koa-mount";
|
|
8
|
-
|
|
9
|
-
const swaggerDefalutUrl = "https://petstore.swagger.io/v2/swagger.json";
|
|
10
|
-
//api显示和管理
|
|
11
|
-
export default function Swagger(app: FastCarApplication): Middleware[] {
|
|
12
|
-
let mlist: Middleware[] = [];
|
|
13
|
-
|
|
14
|
-
let koaConfig: KoaConfig = app.getSetting("koa");
|
|
15
|
-
|
|
16
|
-
if (koaConfig.swagger && koaConfig.swagger.enable) {
|
|
17
|
-
let apiMap = new Map<string, string>();
|
|
18
|
-
let fileMap = new Map<string, string>();
|
|
19
|
-
let apis = koaConfig.swagger.api;
|
|
20
|
-
|
|
21
|
-
if (apis) {
|
|
22
|
-
Object.keys(apis).forEach((key) => {
|
|
23
|
-
let value = apis[key];
|
|
24
|
-
if (!key.startsWith("/")) {
|
|
25
|
-
key = `/${key}`;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
let realValue = value.startsWith("/") ? value : "/" + value;
|
|
29
|
-
apiMap.set(key, realValue);
|
|
30
|
-
fileMap.set(realValue, path.join(app.getResourcePath(), value));
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
//进行设置静态访问路径
|
|
35
|
-
const swaggerUiAssetPath = require("swagger-ui-dist").getAbsoluteFSPath();
|
|
36
|
-
mlist.push(KoaMount("/swagger-ui", koaStatic(swaggerUiAssetPath)) as any);
|
|
37
|
-
|
|
38
|
-
const swaggerTemplate = fs.readFileSync(path.join(swaggerUiAssetPath, "index.html"), "utf-8");
|
|
39
|
-
const fn = async (ctx: Context, next: Next) => {
|
|
40
|
-
let url = ctx.url;
|
|
41
|
-
let item = apiMap.get(url);
|
|
42
|
-
if (!!item) {
|
|
43
|
-
//输出路径
|
|
44
|
-
ctx.type = "text/html";
|
|
45
|
-
ctx.body = swaggerTemplate.replace(swaggerDefalutUrl, item).replace(/\.\//g, "./swagger-ui/");
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
let fp = fileMap.get(url);
|
|
50
|
-
if (fp) {
|
|
51
|
-
if (fs.existsSync(fp)) {
|
|
52
|
-
ctx.body = fs.readFileSync(fp, "utf-8");
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
await next();
|
|
58
|
-
};
|
|
59
|
-
mlist.unshift(fn);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return mlist;
|
|
63
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const koaStatic = require("koa-static");
|
|
6
|
-
const KoaMount = require("koa-mount");
|
|
7
|
-
const swaggerDefalutUrl = "https://petstore.swagger.io/v2/swagger.json";
|
|
8
|
-
//api显示和管理
|
|
9
|
-
function Swagger(app) {
|
|
10
|
-
let mlist = [];
|
|
11
|
-
let koaConfig = app.getSetting("koa");
|
|
12
|
-
if (koaConfig.swagger && koaConfig.swagger.enable) {
|
|
13
|
-
let apiMap = new Map();
|
|
14
|
-
let fileMap = new Map();
|
|
15
|
-
let apis = koaConfig.swagger.api;
|
|
16
|
-
if (apis) {
|
|
17
|
-
Object.keys(apis).forEach((key) => {
|
|
18
|
-
let value = apis[key];
|
|
19
|
-
if (!key.startsWith("/")) {
|
|
20
|
-
key = `/${key}`;
|
|
21
|
-
}
|
|
22
|
-
let realValue = value.startsWith("/") ? value : "/" + value;
|
|
23
|
-
apiMap.set(key, realValue);
|
|
24
|
-
fileMap.set(realValue, path.join(app.getResourcePath(), value));
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
//进行设置静态访问路径
|
|
28
|
-
const swaggerUiAssetPath = require("swagger-ui-dist").getAbsoluteFSPath();
|
|
29
|
-
mlist.push(KoaMount("/swagger-ui", koaStatic(swaggerUiAssetPath)));
|
|
30
|
-
const swaggerTemplate = fs.readFileSync(path.join(swaggerUiAssetPath, "index.html"), "utf-8");
|
|
31
|
-
const fn = async (ctx, next) => {
|
|
32
|
-
let url = ctx.url;
|
|
33
|
-
let item = apiMap.get(url);
|
|
34
|
-
if (!!item) {
|
|
35
|
-
//输出路径
|
|
36
|
-
ctx.type = "text/html";
|
|
37
|
-
ctx.body = swaggerTemplate.replace(swaggerDefalutUrl, item).replace(/\.\//g, "./swagger-ui/");
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
let fp = fileMap.get(url);
|
|
41
|
-
if (fp) {
|
|
42
|
-
if (fs.existsSync(fp)) {
|
|
43
|
-
ctx.body = fs.readFileSync(fp, "utf-8");
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
await next();
|
|
48
|
-
};
|
|
49
|
-
mlist.unshift(fn);
|
|
50
|
-
}
|
|
51
|
-
return mlist;
|
|
52
|
-
}
|
|
53
|
-
exports.default = Swagger;
|
package/target/npmlist.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":"0.1.5","name":"fastcar-koa","dependencies":{"koa-body":{"version":"4.2.0"},"koa-bodyparser":{"version":"4.3.0"},"koa-mount":{"version":"4.0.0"},"koa-range":{"version":"0.3.0"},"koa-router":{"version":"10.1.1"},"koa-static":{"version":"5.0.0"},"koa":{"version":"2.13.4"},"koa2-cors":{"version":"2.0.6"},"swagger-ui-dist":{"version":"4.10.0"}}}
|
package/test/logs/koa.log
DELETED
|
File without changes
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
{"timestamp":"2022-04-10 15:12:31.105","level":"INFO","label":"serverlogger","message":"http server is running in 1234"}
|
|
2
|
-
{"timestamp":"2022-04-10 16:06:15.720","level":"INFO","label":"serverlogger","message":"http server is running in 1234"}
|
|
3
|
-
{"timestamp":"2022-04-10 16:09:07.975","level":"INFO","label":"serverlogger","message":"http server is running in 1234"}
|