koatty 3.5.9 → 3.5.12-1

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 (129) hide show
  1. package/.commitlintrc.js +3 -0
  2. package/.eslintignore +2 -0
  3. package/.huskyrc +5 -0
  4. package/.versionrc.js +16 -0
  5. package/CHANGELOG.md +2 -37
  6. package/README.md +5 -9
  7. package/api-extractor.json +345 -0
  8. package/dist/LICENSE +29 -0
  9. package/dist/README.md +147 -0
  10. package/dist/index.d.ts +363 -19
  11. package/dist/index.js +1266 -26
  12. package/dist/index.mjs +1197 -0
  13. package/dist/package.json +98 -0
  14. package/docs/api/index.md +12 -0
  15. package/docs/api/koatty.apiinput.code.md +11 -0
  16. package/docs/api/koatty.apiinput.data.md +11 -0
  17. package/docs/api/koatty.apiinput.md +22 -0
  18. package/docs/api/koatty.apiinput.message.md +11 -0
  19. package/docs/api/koatty.apioutput.code.md +11 -0
  20. package/docs/api/koatty.apioutput.data.md +11 -0
  21. package/docs/api/koatty.apioutput.md +22 -0
  22. package/docs/api/koatty.apioutput.message.md +11 -0
  23. package/docs/api/koatty.appreadyhookfunc.md +11 -0
  24. package/docs/api/koatty.basecontroller._constructor_.md +20 -0
  25. package/docs/api/koatty.basecontroller._options.md +11 -0
  26. package/docs/api/koatty.basecontroller.app.md +11 -0
  27. package/docs/api/koatty.basecontroller.ctx.md +11 -0
  28. package/docs/api/koatty.basecontroller.fail.md +28 -0
  29. package/docs/api/koatty.basecontroller.init.md +19 -0
  30. package/docs/api/koatty.basecontroller.md +39 -0
  31. package/docs/api/koatty.basecontroller.ok.md +28 -0
  32. package/docs/api/koatty.baseservice._constructor_.md +20 -0
  33. package/docs/api/koatty.baseservice._options.md +11 -0
  34. package/docs/api/koatty.baseservice.app.md +11 -0
  35. package/docs/api/koatty.baseservice.init.md +25 -0
  36. package/docs/api/koatty.baseservice.md +36 -0
  37. package/docs/api/koatty.bindappreadyhook.md +26 -0
  38. package/docs/api/koatty.bootstrap.md +27 -0
  39. package/docs/api/koatty.component.md +27 -0
  40. package/docs/api/koatty.componentscan.md +27 -0
  41. package/docs/api/koatty.configurationscan.md +27 -0
  42. package/docs/api/koatty.controller.md +27 -0
  43. package/docs/api/koatty.httpcontroller.body.md +28 -0
  44. package/docs/api/koatty.httpcontroller.deny.md +26 -0
  45. package/docs/api/koatty.httpcontroller.expires.md +26 -0
  46. package/docs/api/koatty.httpcontroller.fail.md +28 -0
  47. package/docs/api/koatty.httpcontroller.header.md +27 -0
  48. package/docs/api/koatty.httpcontroller.isget.md +19 -0
  49. package/docs/api/koatty.httpcontroller.ismethod.md +26 -0
  50. package/docs/api/koatty.httpcontroller.ispost.md +19 -0
  51. package/docs/api/koatty.httpcontroller.json.md +26 -0
  52. package/docs/api/koatty.httpcontroller.md +35 -0
  53. package/docs/api/koatty.httpcontroller.ok.md +28 -0
  54. package/docs/api/koatty.httpcontroller.param.md +26 -0
  55. package/docs/api/koatty.httpcontroller.redirect.md +27 -0
  56. package/docs/api/koatty.httpcontroller.type.md +27 -0
  57. package/docs/api/koatty.icontroller.__after.md +11 -0
  58. package/docs/api/koatty.icontroller.__befor.md +11 -0
  59. package/docs/api/koatty.icontroller.app.md +11 -0
  60. package/docs/api/koatty.icontroller.ctx.md +11 -0
  61. package/docs/api/koatty.icontroller.fail.md +11 -0
  62. package/docs/api/koatty.icontroller.md +25 -0
  63. package/docs/api/koatty.icontroller.ok.md +11 -0
  64. package/docs/api/koatty.imiddleware.md +20 -0
  65. package/docs/api/koatty.imiddleware.run.md +11 -0
  66. package/docs/api/koatty.iplugin.md +20 -0
  67. package/docs/api/koatty.iplugin.run.md +11 -0
  68. package/docs/api/koatty.iservice.app.md +11 -0
  69. package/docs/api/koatty.iservice.md +20 -0
  70. package/docs/api/koatty.logger.md +11 -0
  71. package/docs/api/koatty.md +51 -0
  72. package/docs/api/koatty.middleware.md +27 -0
  73. package/docs/api/koatty.plugin.md +27 -0
  74. package/docs/api/koatty.service.md +27 -0
  75. package/jest.config.js +0 -2
  76. package/jest_html_reporters.html +1 -1
  77. package/package.json +39 -39
  78. package/rollup.config.js +63 -0
  79. package/scripts/copyright.js +28 -0
  80. package/scripts/postBuild.js +10 -0
  81. package/tsconfig.json +4 -2
  82. package/babel.config.js +0 -21
  83. package/commitlint.config.js +0 -14
  84. package/dist/config/config.d.ts +0 -18
  85. package/dist/config/config.js +0 -25
  86. package/dist/config/config.js.map +0 -1
  87. package/dist/config/middleware.d.ts +0 -23
  88. package/dist/config/middleware.js +0 -34
  89. package/dist/config/middleware.js.map +0 -1
  90. package/dist/config/plugin.d.ts +0 -11
  91. package/dist/config/plugin.js +0 -15
  92. package/dist/config/plugin.js.map +0 -1
  93. package/dist/config/router.d.ts +0 -8
  94. package/dist/config/router.js +0 -32
  95. package/dist/config/router.js.map +0 -1
  96. package/dist/controller/BaseController.d.ts +0 -60
  97. package/dist/controller/BaseController.js +0 -137
  98. package/dist/controller/BaseController.js.map +0 -1
  99. package/dist/controller/HttpController.d.ts +0 -131
  100. package/dist/controller/HttpController.js +0 -215
  101. package/dist/controller/HttpController.js.map +0 -1
  102. package/dist/core/Bootstrap.d.ts +0 -50
  103. package/dist/core/Bootstrap.js +0 -215
  104. package/dist/core/Bootstrap.js.map +0 -1
  105. package/dist/core/Component.d.ts +0 -94
  106. package/dist/core/Component.js +0 -89
  107. package/dist/core/Component.js.map +0 -1
  108. package/dist/core/Constants.d.ts +0 -11
  109. package/dist/core/Constants.js +0 -24
  110. package/dist/core/Constants.js.map +0 -1
  111. package/dist/core/Loader.d.ts +0 -110
  112. package/dist/core/Loader.js +0 -407
  113. package/dist/core/Loader.js.map +0 -1
  114. package/dist/index.js.map +0 -1
  115. package/dist/middleware/PayloadMiddleware.d.ts +0 -11
  116. package/dist/middleware/PayloadMiddleware.js +0 -22
  117. package/dist/middleware/PayloadMiddleware.js.map +0 -1
  118. package/dist/middleware/TraceMiddleware.d.ts +0 -11
  119. package/dist/middleware/TraceMiddleware.js +0 -22
  120. package/dist/middleware/TraceMiddleware.js.map +0 -1
  121. package/dist/service/BaseService.d.ts +0 -33
  122. package/dist/service/BaseService.js +0 -32
  123. package/dist/service/BaseService.js.map +0 -1
  124. package/dist/util/Helper.d.ts +0 -25
  125. package/dist/util/Helper.js +0 -117
  126. package/dist/util/Helper.js.map +0 -1
  127. package/dist/util/Logger.d.ts +0 -27
  128. package/dist/util/Logger.js +0 -41
  129. package/dist/util/Logger.js.map +0 -1
@@ -0,0 +1,51 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [koatty](./koatty.md)
4
+
5
+ ## koatty package
6
+
7
+ ## Classes
8
+
9
+ | Class | Description |
10
+ | --- | --- |
11
+ | [BaseController](./koatty.basecontroller.md) | Base controller BaseController {<!-- -->IController<!-- -->} |
12
+ | [BaseService](./koatty.baseservice.md) | Base class Base |
13
+ | [HttpController](./koatty.httpcontroller.md) | HTTP controller HttpController {<!-- -->IController<!-- -->} |
14
+
15
+ ## Functions
16
+
17
+ | Function | Description |
18
+ | --- | --- |
19
+ | [BindAppReadyHook(func, target)](./koatty.bindappreadyhook.md) | bind AppReadyHookFunc example: export function TestDecorator(): ClassDecorator { return (target: any) =<!-- -->&gt; { BindAppReadyHook((app: Koatty) =<!-- -->&gt; { // todo return Promise.resolve(); }<!-- -->, target) } } |
20
+ | [Bootstrap(bootFunc)](./koatty.bootstrap.md) | Bootstrap application |
21
+ | [Component(identifier)](./koatty.component.md) | Indicates that an decorated class is a "component". |
22
+ | [ComponentScan(scanPath)](./koatty.componentscan.md) | Define project scan path |
23
+ | [ConfigurationScan(scanPath)](./koatty.configurationscan.md) | Define project configuration scan path |
24
+ | [Controller(path)](./koatty.controller.md) | Indicates that an decorated class is a "controller". |
25
+ | [Middleware(identifier)](./koatty.middleware.md) | Indicates that an decorated class is a "middleware". |
26
+ | [Plugin(identifier)](./koatty.plugin.md) | Indicates that an decorated class is a "plugin". |
27
+ | [Service(identifier)](./koatty.service.md) | Indicates that an decorated class is a "service". |
28
+
29
+ ## Interfaces
30
+
31
+ | Interface | Description |
32
+ | --- | --- |
33
+ | [ApiInput](./koatty.apiinput.md) | Interface for Api input |
34
+ | [ApiOutput](./koatty.apioutput.md) | Interface for Api output |
35
+ | [IController](./koatty.icontroller.md) | Interface for Controller |
36
+ | [IMiddleware](./koatty.imiddleware.md) | Interface for Middleware |
37
+ | [IPlugin](./koatty.iplugin.md) | Interface for Plugin |
38
+ | [IService](./koatty.iservice.md) | Interface for Service |
39
+
40
+ ## Variables
41
+
42
+ | Variable | Description |
43
+ | --- | --- |
44
+ | [Logger](./koatty.logger.md) | |
45
+
46
+ ## Type Aliases
47
+
48
+ | Type Alias | Description |
49
+ | --- | --- |
50
+ | [AppReadyHookFunc](./koatty.appreadyhookfunc.md) | |
51
+
@@ -0,0 +1,27 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [koatty](./koatty.md) &gt; [Middleware](./koatty.middleware.md)
4
+
5
+ ## Middleware() function
6
+
7
+ Indicates that an decorated class is a "middleware".
8
+
9
+
10
+ <b>Signature:</b>
11
+
12
+ ```typescript
13
+ export declare function Middleware(identifier?: string): ClassDecorator;
14
+ ```
15
+
16
+ ## Parameters
17
+
18
+ | Parameter | Type | Description |
19
+ | --- | --- | --- |
20
+ | identifier | string | middleware name |
21
+
22
+ <b>Returns:</b>
23
+
24
+ ClassDecorator
25
+
26
+ {<!-- -->ClassDecorator<!-- -->}
27
+
@@ -0,0 +1,27 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [koatty](./koatty.md) &gt; [Plugin](./koatty.plugin.md)
4
+
5
+ ## Plugin() function
6
+
7
+ Indicates that an decorated class is a "plugin".
8
+
9
+
10
+ <b>Signature:</b>
11
+
12
+ ```typescript
13
+ export declare function Plugin(identifier?: string): ClassDecorator;
14
+ ```
15
+
16
+ ## Parameters
17
+
18
+ | Parameter | Type | Description |
19
+ | --- | --- | --- |
20
+ | identifier | string | |
21
+
22
+ <b>Returns:</b>
23
+
24
+ ClassDecorator
25
+
26
+ {<!-- -->ClassDecorator<!-- -->}
27
+
@@ -0,0 +1,27 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [koatty](./koatty.md) &gt; [Service](./koatty.service.md)
4
+
5
+ ## Service() function
6
+
7
+ Indicates that an decorated class is a "service".
8
+
9
+
10
+ <b>Signature:</b>
11
+
12
+ ```typescript
13
+ export declare function Service(identifier?: string): ClassDecorator;
14
+ ```
15
+
16
+ ## Parameters
17
+
18
+ | Parameter | Type | Description |
19
+ | --- | --- | --- |
20
+ | identifier | string | middleware name |
21
+
22
+ <b>Returns:</b>
23
+
24
+ ClassDecorator
25
+
26
+ {<!-- -->ClassDecorator<!-- -->}
27
+
package/jest.config.js CHANGED
@@ -25,8 +25,6 @@ module.exports = {
25
25
  // 将 `ts-jest` 的配置注入到运行时的全局变量中
26
26
  globals: {
27
27
  'ts-jest': {
28
- // 是否使用 babel 配置来转译
29
- babelConfig: true,
30
28
  // 编译 Typescript 所依赖的配置
31
29
  tsconfig: '<rootDir>/tsconfig.json',
32
30
  // 是否启用报告诊断,这里是不启用
@@ -1,5 +1,5 @@
1
1
  <!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Type" content="text/html;charset=utf-8"><meta name="keywords" contect="jest, reporters"><meta name="author" contect="hazyzh"><meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,minimum-scale=1,maximum-scale=1"><link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAHX0lEQVR4Xu2bfWwUVRDAZ/buSsG0Vxq1EAhtL/e2kKISAVEoKJVE4gfiR6wmJsoflpBANLZKqyRIgVg+/CLBNqKoMX5RKWhFsUbRBuJHRCoECLt7x0Jb5IBmr62tx+3dPrNH93Itd7e7xx0ccu+/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cThPHcY/pGdddAYMGbISQTxHxET2D6XCdUvoFz/NPAEBAzx+jAFQ7DMuyjQDwjJ7RK3mdUtrA8/xStXQx4ocZACF76o8lrFbrKkrp3Yg4wsgkqZahlJ5Xu9kDgcBKt9utNnYbHqYBRFi2OZ3OaYhYRCktZBgmod8FGfZ0mCCldEB950IpPS4Ighq0sUbkRJJgok5eDXqXsgKuhvh0fcwA0EX0Pxf4Dws8WYyVxouxAAAAAElFTkSuQmCC"></head><title>Report</title><body><div id="app"></div><textarea style="display: none;" id="resData">
2
- "{\"numFailedTestSuites\":0,\"numFailedTests\":0,\"numPassedTestSuites\":0,\"numPassedTests\":0,\"numPendingTestSuites\":0,\"numPendingTests\":0,\"numRuntimeErrorTestSuites\":0,\"numTodoTests\":0,\"numTotalTestSuites\":0,\"numTotalTests\":0,\"openHandles\":[],\"snapshot\":{\"added\":0,\"didUpdate\":false,\"failure\":false,\"filesAdded\":0,\"filesRemoved\":0,\"filesRemovedList\":[],\"filesUnmatched\":0,\"filesUpdated\":0,\"matched\":0,\"total\":0,\"unchecked\":0,\"uncheckedKeysByFile\":[],\"unmatched\":0,\"updated\":0},\"startTime\":1638373409994,\"success\":false,\"testResults\":[],\"wasInterrupted\":false,\"coverageMap\":{},\"config\":{\"bail\":0,\"changedFilesWithAncestor\":false,\"collectCoverage\":true,\"collectCoverageFrom\":[],\"coverageDirectory\":\"/Users/richen/Workspace/nodejs/koatty/coverage\",\"coverageProvider\":\"babel\",\"coverageReporters\":[\"html\",\"lcov\",\"json\",\"text\",\"clover\",\"text-summary\"],\"detectLeaks\":false,\"detectOpenHandles\":false,\"errorOnDeprecated\":false,\"expand\":false,\"findRelatedTests\":false,\"forceExit\":false,\"json\":false,\"lastCommit\":false,\"listTests\":false,\"logHeapUsage\":false,\"maxConcurrency\":5,\"maxWorkers\":7,\"noStackTrace\":false,\"nonFlagArgs\":[],\"notify\":false,\"notifyMode\":\"failure-change\",\"onlyChanged\":false,\"onlyFailures\":false,\"passWithNoTests\":true,\"projects\":[],\"reporters\":[[\"default\",{}],[\"/Users/richen/Workspace/nodejs/koatty/node_modules/jest-html-reporters/index.js\",{}]],\"rootDir\":\"/Users/richen/Workspace/nodejs/koatty\",\"runTestsByPath\":false,\"skipFilter\":false,\"testFailureExitCode\":1,\"testPathPattern\":\"\",\"testSequencer\":\"/Users/richen/Workspace/nodejs/koatty/node_modules/@jest/test-sequencer/build/index.js\",\"updateSnapshot\":\"new\",\"useStderr\":false,\"watch\":false,\"watchAll\":false,\"watchman\":true},\"endTime\":1638373410060,\"_reporterOptions\":{\"publicPath\":\"/Users/richen/Workspace/nodejs/koatty\",\"filename\":\"jest_html_reporters.html\",\"expand\":false,\"pageTitle\":\"\",\"hideIcon\":false,\"testCommand\":\"npx jest\",\"openReport\":false,\"multipleReportsUnitePath\":\"\",\"failureMessageOnly\":false,\"enableMergeData\":false,\"dataMergeLevel\":1},\"attachInfos\":{}}"
2
+ "{\"numFailedTestSuites\":0,\"numFailedTests\":0,\"numPassedTestSuites\":0,\"numPassedTests\":0,\"numPendingTestSuites\":0,\"numPendingTests\":0,\"numRuntimeErrorTestSuites\":0,\"numTodoTests\":0,\"numTotalTestSuites\":0,\"numTotalTests\":0,\"openHandles\":[],\"snapshot\":{\"added\":0,\"didUpdate\":false,\"failure\":false,\"filesAdded\":0,\"filesRemoved\":0,\"filesRemovedList\":[],\"filesUnmatched\":0,\"filesUpdated\":0,\"matched\":0,\"total\":0,\"unchecked\":0,\"uncheckedKeysByFile\":[],\"unmatched\":0,\"updated\":0},\"startTime\":1640061171870,\"success\":false,\"testResults\":[],\"wasInterrupted\":false,\"coverageMap\":{},\"config\":{\"bail\":0,\"changedFilesWithAncestor\":false,\"collectCoverage\":true,\"collectCoverageFrom\":[],\"coverageDirectory\":\"/Users/richen/Workspace/nodejs/koatty/coverage\",\"coverageProvider\":\"babel\",\"coverageReporters\":[\"html\",\"lcov\",\"json\",\"text\",\"clover\",\"text-summary\"],\"detectLeaks\":false,\"detectOpenHandles\":false,\"errorOnDeprecated\":false,\"expand\":false,\"findRelatedTests\":false,\"forceExit\":false,\"json\":false,\"lastCommit\":false,\"listTests\":false,\"logHeapUsage\":false,\"maxConcurrency\":5,\"maxWorkers\":7,\"noStackTrace\":false,\"nonFlagArgs\":[],\"notify\":false,\"notifyMode\":\"failure-change\",\"onlyChanged\":false,\"onlyFailures\":false,\"passWithNoTests\":true,\"projects\":[],\"reporters\":[[\"default\",{}],[\"/Users/richen/Workspace/nodejs/koatty/node_modules/jest-html-reporters/index.js\",{}]],\"rootDir\":\"/Users/richen/Workspace/nodejs/koatty\",\"runTestsByPath\":false,\"skipFilter\":false,\"testFailureExitCode\":1,\"testPathPattern\":\"\",\"testSequencer\":\"/Users/richen/Workspace/nodejs/koatty/node_modules/@jest/test-sequencer/build/index.js\",\"updateSnapshot\":\"new\",\"useStderr\":false,\"watch\":false,\"watchAll\":false,\"watchman\":true},\"endTime\":1640061171915,\"_reporterOptions\":{\"publicPath\":\"/Users/richen/Workspace/nodejs/koatty\",\"filename\":\"jest_html_reporters.html\",\"expand\":false,\"pageTitle\":\"\",\"hideIcon\":false,\"testCommand\":\"npx jest\",\"openReport\":false,\"multipleReportsUnitePath\":\"\",\"failureMessageOnly\":false,\"enableMergeData\":false,\"dataMergeLevel\":1},\"attachInfos\":{}}"
3
3
  </textarea><script>/*! Copyright Harry All rights reserved. */!function(n){var r={};function o(t){if(r[t])return r[t].exports;var e=r[t]={i:t,l:!1,exports:{}};return n[t].call(e.exports,e,e.exports,o),e.l=!0,e.exports}o.m=n,o.c=r,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)o.d(n,r,function(t){return e[t]}.bind(null,r));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=1103)}([function(t,e,n){"use strict";t.exports=n(447)},function(t,e,n){t.exports=n(905)()},function(t,e,n){var r;
4
4
  /*!
5
5
  Copyright (c) 2017 Jed Watson.
package/package.json CHANGED
@@ -1,33 +1,37 @@
1
1
  {
2
2
  "name": "koatty",
3
- "version": "3.5.9",
3
+ "version": "3.5.12-1",
4
4
  "description": "Koa2 + Typescript = koatty. Use Typescript's decorator implement auto injection.",
5
5
  "scripts": {
6
- "build": "del-cli --force dist && tsc",
6
+ "build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
7
+ "build:cp": "node scripts/postBuild && copyfiles package.json LICENSE README.md dist/",
8
+ "build:js": "del-cli --force dist && npx rollup -c",
9
+ "build:doc": "del-cli --force docs/api && npx api-documenter markdown --input temp --output docs/api",
10
+ "build:dts": "del-cli --force temp && npx tsc && npx api-extractor run --local --verbose",
7
11
  "eslint": "eslint --ext .ts,.js ./",
8
12
  "prepublishOnly": "npm test && npm run build",
9
- "release": "npm run prepublishOnly && standard-version",
13
+ "prerelease": "npm test && npm run build",
14
+ "release": "standard-version",
15
+ "release:pre": "npm run release -- --prerelease",
16
+ "release:major": "npm run release -- --release-as major",
17
+ "release:minor": "npm run release -- --release-as minor",
10
18
  "pub": "git push --follow-tags origin && npm publish",
11
19
  "test": "npm run eslint && jest --passWithNoTests",
12
20
  "test:cov": "jest --collectCoverage --detectOpenHandles",
13
21
  "version": "conventional-changelog -p angular -i CHANGELOG.md -s"
14
22
  },
15
23
  "main": "./dist/index.js",
24
+ "exports": {
25
+ "require": "./index.js",
26
+ "import": "./index.mjs"
27
+ },
28
+ "directories": {
29
+ "doc": "docs"
30
+ },
16
31
  "repository": {
17
32
  "type": "git",
18
33
  "url": "git+https://github.com/thinkkoa/koatty.git"
19
34
  },
20
- "keywords": [
21
- "web",
22
- "typescript",
23
- "framework",
24
- "mvc",
25
- "koa2",
26
- "restful",
27
- "agile",
28
- "koatty",
29
- "thinkkoa"
30
- ],
31
35
  "engines": {
32
36
  "node": ">12.0.0"
33
37
  },
@@ -47,27 +51,29 @@
47
51
  }
48
52
  ],
49
53
  "devDependencies": {
50
- "@babel/core": "^7.x.x",
51
- "@babel/plugin-proposal-decorators": "^7.x.x",
52
- "@babel/preset-env": "^7.x.x",
53
- "@babel/preset-typescript": "^7.x.x",
54
- "@commitlint/cli": "^12.x.x",
55
- "@commitlint/config-conventional": "^15.x.x",
54
+ "@microsoft/api-documenter": "^7.x.x",
55
+ "@microsoft/api-extractor": "^7.x.x",
56
+ "@rollup/plugin-json": "^4.x.x",
56
57
  "@types/jest": "^27.x.x",
57
58
  "@types/koa": "^2.x.x",
58
- "@types/koa__router": "^8.0.9",
59
+ "@types/koa__router": "^8.x.x",
59
60
  "@types/node": "^16.x.x",
60
- "@types/uuid": "^8.3.3",
61
- "@types/ws": "^8.2.0",
61
+ "@types/uuid": "^8.x.x",
62
+ "@types/ws": "^8.x.x",
62
63
  "@typescript-eslint/eslint-plugin": "^5.x.x",
63
64
  "@typescript-eslint/parser": "^5.x.x",
65
+ "commitlint": "^15.x.x",
66
+ "commitlint-config-gitmoji": "^2.x.x",
64
67
  "conventional-changelog-cli": "^2.x.x",
68
+ "copyfiles": "^2.x.x",
65
69
  "del-cli": "^4.x.x",
66
70
  "eslint": "^8.x.x",
67
71
  "eslint-plugin-jest": "^25.x.x",
68
72
  "husky": "^7.x.x",
69
73
  "jest": "^27.x.x",
70
74
  "jest-html-reporters": "^2.x.x",
75
+ "rollup": "^2.x.x",
76
+ "rollup-plugin-typescript2": "^0.x.x",
71
77
  "standard-version": "^9.x.x",
72
78
  "ts-jest": "^27.x.x",
73
79
  "ts-node": "^10.x.x",
@@ -75,24 +81,18 @@
75
81
  },
76
82
  "dependencies": {
77
83
  "koa": "^2.13.4",
78
- "koatty_config": "^1.0.4",
79
- "koatty_container": "^1.6.8",
80
- "koatty_core": "^1.3.38",
84
+ "koatty_config": "^1.0.6",
85
+ "koatty_container": "^1.6.12",
86
+ "koatty_core": "^1.4.6",
81
87
  "koatty_exception": "^1.0.6",
82
- "koatty_lib": "^1.2.6",
88
+ "koatty_lib": "^1.2.8",
83
89
  "koatty_loader": "^1.0.2",
84
- "koatty_logger": "^1.2.12",
90
+ "koatty_logger": "^1.3.12",
85
91
  "koatty_payload": "^1.3.10",
86
- "koatty_router": "^1.5.12",
87
- "koatty_serve": "^1.3.10",
88
- "koatty_trace": "^1.4.26",
92
+ "koatty_router": "^1.6.2",
93
+ "koatty_serve": "^1.4.2",
94
+ "koatty_trace": "^1.5.0",
89
95
  "reflect-metadata": "^0.1.13",
90
- "tslib": "^2.3.1",
91
- "uuid": "^8.3.2"
92
- },
93
- "husky": {
94
- "hooks": {
95
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
96
- }
96
+ "tslib": "^2.3.1"
97
97
  }
98
- }
98
+ }
@@ -0,0 +1,63 @@
1
+ /*
2
+ * @Description:
3
+ * @Usage:
4
+ * @Author: richen
5
+ * @Date: 2021-12-17 10:20:44
6
+ * @LastEditTime: 2021-12-18 11:58:46
7
+ */
8
+ import json from "@rollup/plugin-json";
9
+ import typescript from 'rollup-plugin-typescript2';
10
+ // import babel from '@rollup/plugin-babel';
11
+
12
+ export default [
13
+ {
14
+ input: './src/index.ts',
15
+ output: [{
16
+ format: 'cjs',
17
+ file: './dist/index.js',
18
+ banner: require('./scripts/copyright')
19
+ }],
20
+ plugins: [
21
+ // babel({
22
+ // babelHelpers: "runtime",
23
+ // configFile: './babel.config.js',
24
+ // exclude: 'node_modules/**',
25
+ // }),
26
+ json(),
27
+ typescript({
28
+ tsconfigOverride: {
29
+ compilerOptions: {
30
+ declaration: false,
31
+ declarationMap: false,
32
+ module: "ESNext"
33
+ }
34
+ }
35
+ })
36
+ ]
37
+ },
38
+ {
39
+ input: './src/index.ts',
40
+ output: [{
41
+ format: 'es',
42
+ file: './dist/index.mjs',
43
+ banner: require('./scripts/copyright')
44
+ }],
45
+ plugins: [
46
+ // babel({
47
+ // babelHelpers: "runtime",
48
+ // configFile: './babel.config.js',
49
+ // exclude: 'node_modules/**',
50
+ // }),
51
+ json(),
52
+ typescript({
53
+ tsconfigOverride: {
54
+ compilerOptions: {
55
+ declaration: false,
56
+ declarationMap: false,
57
+ module: "ESNext"
58
+ }
59
+ }
60
+ })
61
+ ]
62
+ }
63
+ ]
@@ -0,0 +1,28 @@
1
+ /**
2
+ * 扩展Date的Format函数
3
+ * 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符,
4
+ * 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
5
+ * @param {[type]} fmt [description]
6
+ */
7
+ Date.prototype.Format = function (fmt) { //author: meizz
8
+ var o = {
9
+ "M+": this.getMonth() + 1, //月份
10
+ "d+": this.getDate(), //日
11
+ "h+": this.getHours(), //小时
12
+ "m+": this.getMinutes(), //分
13
+ "s+": this.getSeconds(), //秒
14
+ "S": this.getMilliseconds() //毫秒
15
+ };
16
+ if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
17
+ for (var k in o)
18
+ if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
19
+ return fmt;
20
+ }
21
+
22
+ module.exports = `/*!
23
+ * @Author: richen
24
+ * @Date: ${(new Date()).Format("yyyy-MM-dd hh:mm:ss")}
25
+ * @License: BSD (3-Clause)
26
+ * @Copyright (c) - <richenlin(at)gmail.com>
27
+ * @HomePage: https://koatty.org/
28
+ */`
@@ -0,0 +1,10 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ // remove private / protected index.d.ts
5
+ (() => {
6
+ let content = fs.readFileSync(path.resolve(__dirname, '../dist/index.d.ts'), 'utf-8');
7
+ content = content.replace(/\s+(private|protected).+;/g, '');
8
+ content = require('./copyright') + '\n' + content;
9
+ fs.writeFileSync(path.resolve(__dirname, '../dist/index.d.ts'), content, 'utf-8');
10
+ })();
package/tsconfig.json CHANGED
@@ -11,9 +11,10 @@
11
11
  // "checkJs": true, /* Report errors in .js files. */
12
12
  // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
13
13
  "declaration": true /* Generates corresponding '.d.ts' file. */,
14
+ "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
14
15
  "sourceMap": true /* Generates corresponding '.map' file. */,
15
16
  // "outFile": "./", /* Concatenate and emit output to single file. */
16
- "outDir": "./dist/" /* Redirect output structure to the directory. */,
17
+ "outDir": "./temp" /* Redirect output structure to the directory. */,
17
18
  // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
18
19
  "removeComments": false /* Do not emit comments to output. */,
19
20
  // "noEmit": true /* Do not emit outputs. */,
@@ -21,7 +22,7 @@
21
22
  "downlevelIteration": true /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */,
22
23
  // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
23
24
  /* Strict Type-Checking Options */
24
- "stripInternal": true /* Enable all strict type-checking options. */,
25
+ "stripInternal": true, /* Enable all strict type-checking options. */
25
26
  "noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
26
27
  // "strictNullChecks": true, /* Enable strict null checks. */
27
28
  "noImplicitThis": false /* Raise error on 'this' expressions with an implied 'any' type. */,
@@ -48,6 +49,7 @@
48
49
  "allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */,
49
50
  "resolveJsonModule": true,
50
51
  "esModuleInterop": true,
52
+ "useUnknownInCatchVariables": false, /* Default catch clause variables as unknown instead of any. */
51
53
  /* Source Map Options */
52
54
  // "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
53
55
  // "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
package/babel.config.js DELETED
@@ -1,21 +0,0 @@
1
- /*
2
- * @Description : babel配置
3
- * @usage : 用于jest执行用例
4
- */
5
-
6
- module.exports = {
7
- presets: [
8
- [
9
- '@babel/preset-env',
10
- {
11
- targets: {
12
- node: 'current',
13
- },
14
- },
15
- ],
16
- '@babel/preset-typescript',
17
- ],
18
- plugins: [
19
- ['@babel/plugin-proposal-decorators', { 'legacy': true }]
20
- ],
21
- };
@@ -1,14 +0,0 @@
1
- /*
2
- *
3
- */
4
- module.exports = {
5
- extends: ['@commitlint/config-conventional'],
6
- rules: {
7
- 'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore']],
8
- 'type-empty': [2, 'never'],
9
- 'scope-enum': [0], // 不校验scope类型
10
- 'scope-empty': [0], // 不校验scope是否设置
11
- 'subject-case': [0], // 不校验描述的字符格式
12
- 'subject-min-length': [2, 'always', 5], // 描述至少5个字符
13
- },
14
- };
@@ -1,18 +0,0 @@
1
- declare const _default: {
2
- app_port: number;
3
- app_host: string;
4
- protocol: string;
5
- open_trace: boolean;
6
- http_timeout: number;
7
- key_file: string;
8
- crt_file: string;
9
- encoding: string;
10
- logs_path: string;
11
- };
12
- /**
13
- * @ author: richen
14
- * @ copyright: Copyright (c) - <richenlin(at)gmail.com>
15
- * @ license: BSD (3-Clause)
16
- * @ version: 2020-01-19 15:41:30
17
- */
18
- export default _default;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * @ author: richen
5
- * @ copyright: Copyright (c) - <richenlin(at)gmail.com>
6
- * @ license: BSD (3-Clause)
7
- * @ version: 2020-01-19 15:41:30
8
- */
9
- exports.default = {
10
- /*app config*/
11
- app_port: 3000,
12
- app_host: "",
13
- protocol: "http",
14
- open_trace: false,
15
- http_timeout: 10,
16
- key_file: "",
17
- crt_file: "",
18
- encoding: "utf-8",
19
- // logs_level: "DEBUG", // Level log is printed to the console, "DEBUG" | "INFO" | "WARN" | "ERROR"
20
- // logs_console: true, // Whether to console logs
21
- // logs_write: false, // Whether to store logs
22
- // logs_write_level: "WARN", // Level log is printed to the file, "DEBUG" | "INFO" | "WARN" | "ERROR"
23
- logs_path: process.env.ROOT_PATH + "/logs", // Log file directory
24
- };
25
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config/config.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,kBAAe;IACX,cAAc;IACd,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,KAAK;IACjB,YAAY,EAAE,EAAE;IAChB,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,OAAO;IAEjB,mGAAmG;IACnG,iDAAiD;IACjD,8CAA8C;IAC9C,qGAAqG;IACrG,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,GAAG,OAAO,EAAE,qBAAqB;CAEpE,CAAC"}
@@ -1,23 +0,0 @@
1
- declare const _default: {
2
- list: any[];
3
- config: {
4
- TraceMiddleware: {
5
- HeaderName: string;
6
- IdFactory: (<T extends ArrayLike<number>>(options: import("uuid").V4Options, buffer: T, offset?: number) => T) & ((options?: import("uuid").V4Options) => string);
7
- };
8
- PayloadMiddleware: {
9
- extTypes: {
10
- json: string[];
11
- form: string[];
12
- text: string[];
13
- multipart: string[];
14
- xml: string[];
15
- };
16
- limit: string;
17
- encoding: string;
18
- multiples: boolean;
19
- keepExtensions: boolean;
20
- };
21
- };
22
- };
23
- export default _default;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /**
4
- * @ author: richen
5
- * @ copyright: Copyright (c) - <richenlin(at)gmail.com>
6
- * @ license: BSD (3-Clause)
7
- * @ version: 2020-04-30 14:52:34
8
- */
9
- const uuid_1 = require("uuid");
10
- exports.default = {
11
- // List of loaded middleware(except for the middleware loaded by default),
12
- // executed in the order of elements
13
- list: [],
14
- config: {
15
- "TraceMiddleware": {
16
- HeaderName: 'X-Request-Id',
17
- IdFactory: uuid_1.v4,
18
- },
19
- "PayloadMiddleware": {
20
- "extTypes": {
21
- "json": ['application/json'],
22
- "form": ['application/x-www-form-urlencoded'],
23
- "text": ['text/plain'],
24
- "multipart": ['multipart/form-data'],
25
- "xml": ['text/xml']
26
- },
27
- "limit": '20mb',
28
- "encoding": 'utf-8',
29
- "multiples": true,
30
- "keepExtensions": true
31
- },
32
- }
33
- };
34
- //# sourceMappingURL=middleware.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/config/middleware.ts"],"names":[],"mappings":";;AAAA;;;;;GAKG;AACH,+BAAoC;AAEpC,kBAAe;IACX,2EAA2E;IAC3E,oCAAoC;IACpC,IAAI,EAAE,EAAE;IACR,MAAM,EAAE;QACJ,iBAAiB,EAAE;YACf,UAAU,EAAE,cAAc;YAC1B,SAAS,EAAE,SAAM;SACpB;QACD,mBAAmB,EAAE;YACjB,UAAU,EAAE;gBACR,MAAM,EAAE,CAAC,kBAAkB,CAAC;gBAC5B,MAAM,EAAE,CAAC,mCAAmC,CAAC;gBAC7C,MAAM,EAAE,CAAC,YAAY,CAAC;gBACtB,WAAW,EAAE,CAAC,qBAAqB,CAAC;gBACpC,KAAK,EAAE,CAAC,UAAU,CAAC;aACtB;YACD,OAAO,EAAE,MAAM;YACf,UAAU,EAAE,OAAO;YACnB,WAAW,EAAE,IAAI;YACjB,gBAAgB,EAAE,IAAI;SACzB;KACJ;CACJ,CAAC"}
@@ -1,11 +0,0 @@
1
- /**
2
- * @ author: richen
3
- * @ copyright: Copyright (c) - <richenlin(at)gmail.com>
4
- * @ license: BSD (3-Clause)
5
- * @ version: 2020-04-30 14:52:34
6
- */
7
- declare const _default: {
8
- list: any[];
9
- config: {};
10
- };
11
- export default _default;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- /**
3
- * @ author: richen
4
- * @ copyright: Copyright (c) - <richenlin(at)gmail.com>
5
- * @ license: BSD (3-Clause)
6
- * @ version: 2020-04-30 14:52:34
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.default = {
10
- // List of loaded plugins, executed in the order of elements
11
- list: [],
12
- config: { // plugin configuration
13
- }
14
- };
15
- //# sourceMappingURL=plugin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/config/plugin.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,kBAAe;IACX,4DAA4D;IAC5D,IAAI,EAAE,EAAE;IACR,MAAM,EAAE,EAAE,uBAAuB;KAEhC;CACJ,CAAC"}
@@ -1,8 +0,0 @@
1
- declare const _default: {};
2
- /**
3
- * @ author: richen
4
- * @ copyright: Copyright (c) - <richenlin(at)gmail.com>
5
- * @ license: BSD (3-Clause)
6
- * @ version: 2019-11-01 18:37:35
7
- */
8
- export default _default;