koatty 3.11.9 → 3.12.0

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/.rollup.config.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * @Usage:
4
4
  * @Author: richen
5
5
  * @Date: 2021-12-17 10:20:44
6
- * @LastEditTime: 2024-11-29 17:33:44
6
+ * @LastEditTime: 2025-03-15 18:06:51
7
7
  */
8
8
  import commonjs from '@rollup/plugin-commonjs';
9
9
  import json from "@rollup/plugin-json";
@@ -12,6 +12,7 @@ import { builtinModules } from 'module';
12
12
  import del from "rollup-plugin-delete";
13
13
  import typescript from 'rollup-plugin-typescript2';
14
14
  // import babel from '@rollup/plugin-babel';
15
+ // import terser from '@rollup/plugin-terser';
15
16
  const pkg = require('./package.json');
16
17
 
17
18
  export default [
@@ -49,11 +50,17 @@ export default [
49
50
  module: "ESNext"
50
51
  }
51
52
  }
52
- })
53
+ }),
54
+ // terser({
55
+ // format: { comments: false },
56
+ // compress: false,
57
+ // mangle: false
58
+ // }),
53
59
  ],
54
60
  external: [
55
61
  ...builtinModules, // 排除 Node.js 内置模块
56
62
  ...Object.keys(pkg.dependencies || {}), // 排除 package.json 中的外部依赖
63
+ ...Object.keys(pkg.devDependencies || {}),
57
64
  ],
58
65
  },
59
66
 
package/CHANGELOG.md CHANGED
@@ -2,23 +2,30 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
- ### [3.11.9](https://github.com/thinkkoa/koatty/compare/v3.11.8...v3.11.9) (2025-01-14)
5
+ ## [3.12.0](https://github.com/thinkkoa/koatty/compare/v3.11.9...v3.12.0) (2025-03-15)
6
6
 
7
- ### [3.11.8](https://github.com/thinkkoa/koatty/compare/v3.11.7...v3.11.8) (2025-01-14)
8
7
 
8
+ ### Features
9
9
 
10
- ### Bug Fixes
11
-
12
- * 调整app.env定义逻辑 ([eb4ae59](https://github.com/thinkkoa/koatty/commit/eb4ae5983831543e93eabac52c272f0dad2fb907))
13
- * enable debug mode and update dependencies ([651f1c8](https://github.com/thinkkoa/koatty/commit/651f1c85c85fcd166ee8f0c07d445baf4ffd662a))
14
-
15
- ### [3.11.7](https://github.com/thinkkoa/koatty/compare/v3.11.6...v3.11.7) (2024-12-06)
16
-
17
-
18
- ### Bug Fixes
19
-
20
- * export koatty_exception ([93e96bc](https://github.com/thinkkoa/koatty/commit/93e96bc703da57c0e555d5b384f0eb93501e3cfb))
10
+ * add GraphQL support and update router configuration ([f6fff69](https://github.com/thinkkoa/koatty/commit/f6fff69edca036450aba02400c2a8debead9db80))
21
11
 
12
+ ### [3.11.9](https://github.com/thinkkoa/koatty/compare/v3.11.8...v3.11.9) (2025-01-14)
13
+
14
+ ### [3.11.8](https://github.com/thinkkoa/koatty/compare/v3.11.7...v3.11.8) (2025-01-14)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * 调整app.env定义逻辑 ([eb4ae59](https://github.com/thinkkoa/koatty/commit/eb4ae5983831543e93eabac52c272f0dad2fb907))
20
+ * enable debug mode and update dependencies ([651f1c8](https://github.com/thinkkoa/koatty/commit/651f1c85c85fcd166ee8f0c07d445baf4ffd662a))
21
+
22
+ ### [3.11.7](https://github.com/thinkkoa/koatty/compare/v3.11.6...v3.11.7) (2024-12-06)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * export koatty_exception ([93e96bc](https://github.com/thinkkoa/koatty/commit/93e96bc703da57c0e555d5b384f0eb93501e3cfb))
28
+
22
29
  ### [3.11.6](https://github.com/thinkkoa/koatty/compare/v3.11.4-2...v3.11.6) (2024-12-05)
23
30
 
24
31
 
package/README.md CHANGED
@@ -1,179 +1,151 @@
1
- # koatty
1
+ # Koatty 🚀
2
2
 
3
- Koa2 + Typescript + IOC = koatty.
3
+ [![npm version](https://img.shields.io/npm/v/koatty)](https://www.npmjs.com/package/koatty)
4
+ [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
4
5
 
5
- Use Typescript's decorator implement IOC and AOP.
6
+ Koa2 + Typescript + IOC = koatty. **Koatty** is a progressive Node.js framework for building efficient and scalable server-side applications. Perfect for crafting enterprise-level APIs, microservices, and full-stack applications with TypeScript excellence.
6
7
 
7
- [![Version npm](https://img.shields.io/npm/v/koatty.svg?style=flat-square)](https://www.npmjs.com/package/koatty)[![npm Downloads](https://img.shields.io/npm/dm/koatty.svg?style=flat-square)](https://npmcharts.com/compare/koatty?minimal=true)
8
+ ## Why Koatty? 💡
8
9
 
9
- ## New features
10
+ - 🚄 **High Performance**: Built on top of Koa2 with optimized architecture
11
+ - 🧩 **Full-Featured**: Supports gRPC, HTTP, WebSocket, Schedule tasks, and more
12
+ - 🧠 **TypeScript First**: Native TypeScript support with elegant OOP design
13
+ - 🌀 **Spring-like IOC Container**: Powerful dependency injection system with autowiring
14
+ - ✂️ **AOP Support**: Aspect-oriented programming with decorator-based interceptors
15
+ - 🔌 **Extensible Architecture**: Plugin system with dependency injection
16
+ - 📦 **Modern Tooling**: CLI scaffolding, testing utilities, and production-ready configs
17
+ - 🌐 **Protocol Agnostic**: Write once, deploy as HTTP/gRPC/WebSocket services
18
+
19
+
20
+ ## New features ✨
10
21
 
11
22
  * HTTP、HTTPS、HTTP2、gRPC、WebSocket server.✔️
12
- * Support loading environment configuration, parsing command line parameters (process.argv) and environment variables (process.env).✔️
23
+ * Support loading configurations based on the environment, support command-line argument parsing(process.argv), and support environment variable parsing(process.env).✔️
13
24
  * `@ExceptionHandler()` Register global exception handling.✔️
14
- * graceful shutdown and pre-exit event.✔️
15
- * custom decorator based on app events.✔️
16
- * GraphQL supporting. 💪
25
+ * Graceful shutdown and pre-exit event.✔️
26
+ * Supports custom decorators, bound to app events for execution.✔️
27
+ * GraphQL supporting. ✔️
17
28
  * OpenTelemetry . 💪
18
29
 
19
30
 
20
- ## Documentation
21
-
22
- [koatty_doc_CN](https://koatty.org/) (In progress💪)
31
+ ## Core Features ✨
23
32
 
24
-
25
- ## Installation CLI tools
26
-
27
- ```shell
28
- npm i -g koatty_cli
33
+ ### 📡 Multi-Protocol Support
34
+ ```typescript
35
+ // config/config.ts
36
+ export default {
37
+ ...
38
+ protocol: "grpc", // Server protocol 'http' | 'https' | 'http2' | 'grpc' | 'ws' | 'wss'
39
+ ...
40
+ }
29
41
  ```
30
42
 
31
- ## Quick Start
43
+ ### 💉 Dependency Injection
44
+ ```typescript
45
+ @Service()
46
+ export class UserService {
47
+ async findUser(id: number) {
48
+ return { id, name: 'Koatty User' };
49
+ }
50
+ }
32
51
 
33
- ### 1.Create Project
52
+ @Controller()
53
+ export class IndexController {
54
+ app: App;
55
+ ctx: KoattyContext;
56
+ ...
34
57
 
35
- ```shell
36
- kt new projectName
58
+ @Autowired()
59
+ private userService: UserService;
37
60
 
61
+ async test(id: number) {
62
+ const info = await this.userService.findUser(id);
63
+ ...
64
+ }
65
+ }
38
66
  ```
39
67
 
40
- ### 2. Install deps
68
+ ### ✂️ Aspect-Oriented Programming
69
+ ```javascript
70
+ @Aspect()
71
+ export class LogAspect implements IAspect {
72
+ app: App;
41
73
 
42
- ```
43
- cd ./projectName
74
+ run() {
75
+ console.log('LogAspect');
76
+ }
77
+ }
44
78
 
45
- npm i
79
+ // Apply aspect to controller
80
+ @Controller()
81
+ @BeforeEach(LogAspect)
82
+ export class UserController {}
46
83
  ```
47
84
 
48
- ### 3. Start up
49
-
85
+ ### 🔌 Plugin System
86
+ ```javascript
87
+ // plugin/logger.ts
88
+ export class LoggerPlugin implements IPlugin {
89
+ app: App;
90
+
91
+ run() {
92
+ // todo something or hook on app.event
93
+ Logger.Debug("LoggerPlugin");
94
+ return Promise.resolve();
95
+ }
96
+ }
50
97
  ```
51
- npm run dev
52
98
 
53
- // or
54
- npm start
55
- ```
56
99
 
57
- ## Code style
100
+ ## Benchmarks 📊
58
101
 
59
- default Controller:
102
+ | Framework | Requests/sec | Latency | Memory Usage |
103
+ | ---------- | ------------ | ------- | ------------ |
104
+ | **Koatty** | 13,321 | 1.43ms | 54MB |
105
+ | Express | 12,456 | 1.45ms | 52MB |
106
+ | NestJS | 11,892 | 1.51ms | 63MB |
60
107
 
61
- ```javascript
62
- import { Controller, Autowired, GetMapping, RequestBody, PathVariable,
63
- PostMapping, RequestMapping, RequestMethod, Valid, Output } from "koatty";
64
- import { TestDTO } from "../model/dto/TestDTO";
65
- import { TestService } from "../service/TestService";
66
- import { App } from "../App";
108
+ *Tested on AWS t3.micro with 100 concurrent connections*
67
109
 
68
- @Controller()
69
- export class IndexController {
70
- app: App;
71
- ctx: KoattyContext;
110
+ ## Documentation 📚
72
111
 
73
- @Autowired()
74
- private testService: TestService;
75
-
76
- /**
77
- * constructor
78
- *
79
- */
80
- constructor(ctx: KoattyContext) {
81
- this.ctx = ctx;
82
- }
112
+ - [中文文档](https://koatty.org/)
113
+ - [Getting Started Guide](https://github.com/Koatty/koatty_doc/blob/master/docs/README-en.md)
114
+ - [API Reference](https://koatty.org/#/?id=api)
115
+ - [Recipes & Best Practices](https://github.com/Koatty/koatty_awesome)
116
+ - [Example](https://github.com/Koatty/koatty_demo)
83
117
 
84
- @GetMapping('/')
85
- index() {
86
- return Output.ok("Hello, koatty!");
87
- }
88
118
 
89
- @RequestMapping("/:name", RequestMethod.ALL)
90
- async default(@PathVariable("name") @Valid("IsNotEmpty") name: string) {
91
- try {
92
- const info = await this.testService.sayHello(name);
93
- return Output.ok(this.ctx, "success", info);
94
- } catch (err: Error) {
95
- return Output.fail(this.ctx, err.message));
96
- }
97
- }
119
+ ## Quick Start ⚡
98
120
 
99
- @PostMapping("/test")
100
- @Validated() //need DTOClass
101
- test(@RequestParam() params: TestDTO) {
102
- return Output.ok(this.ctx, "test", params);
103
- }
104
- }
121
+ 1. **Install CLI**:
122
+ ```bash
123
+ npm install -g koatty_cli
105
124
  ```
106
125
 
107
- ## How to do Unit Testing
108
-
109
- >only support `jest` UT framework now
110
-
111
- ```javascript
112
- import request from 'supertest';
113
- import { ExecBootStrap } from 'koatty';
114
- import { App } from '../src/App';
115
-
116
- describe('UT example', () => {
117
-
118
- let app: KoattyApplication;
119
- beforeAll(async () => {
120
- jest.useFakeTimers();
121
- // test env
122
- process.env.KOATTY_ENV = 'ts-node';
123
- app = await ExecBootStrap()(App);
124
- // app.use(async (ctx: any) => {
125
- // ctx.body = 'Hello, World!';
126
- // });
127
- });
128
-
129
- afterAll(done => {
130
- done();
131
- jest.clearAllMocks();
132
- });
133
-
134
- it('request', async () => {
135
- const res = await request(app.callback()).get('/');
136
- expect(res.status).toBe(200);
137
- });
138
- });
126
+ 2. **Create Project**:
127
+ ```bash
128
+ koatty new awesome-app
129
+ ```
139
130
 
131
+ 3. **Run Development Server**:
132
+ ```bash
133
+ cd awesome-app
134
+ npm run dev
140
135
  ```
141
136
 
142
- ## How to debug
143
137
 
144
- if you use vscode , edit the `.vscode/launch.json` , like this:
145
- ```
146
- {
147
- "version": "0.2.0",
148
- "configurations": [
149
- {
150
- "type": "node",
151
- "request": "launch",
152
- "name": "TS Program",
153
- "args": [
154
- "${workspaceRoot}/src/App.ts"
155
- ],
156
- "runtimeArgs": [
157
- "--nolazy",
158
- "-r",
159
- "ts-node/register"
160
- ],
161
- "sourceMaps": true,
162
- "cwd": "${workspaceRoot}",
163
- "protocol": "inspector",
164
- "outputCapture": "std",
165
- "internalConsoleOptions": "neverOpen"
166
- }
167
- ]
168
- }
169
- ```
170
- Select `TS Program` to debug run. Try to call `http://localhost:3000/` .
138
+ ## Community 🌍
139
+
140
+ - [GitHub Discussions](https://github.com/Koatty/koatty/discussions)
171
141
 
172
- ## Example
142
+ ## Contributors ✨
173
143
 
174
- Check out the [quick start example][quick-example].
144
+ Thanks to these amazing developers:
175
145
 
176
- [quick-example]: https://github.com/Koatty/koatty_template
146
+ <!-- Add contributor list here -->
177
147
 
178
148
 
149
+ ## License 📄
179
150
 
151
+ BSD-3 © [Koatty Team](https://github.com/Koatty)
package/dist/README.md CHANGED
@@ -1,179 +1,151 @@
1
- # koatty
1
+ # Koatty 🚀
2
2
 
3
- Koa2 + Typescript + IOC = koatty.
3
+ [![npm version](https://img.shields.io/npm/v/koatty)](https://www.npmjs.com/package/koatty)
4
+ [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
4
5
 
5
- Use Typescript's decorator implement IOC and AOP.
6
+ Koa2 + Typescript + IOC = koatty. **Koatty** is a progressive Node.js framework for building efficient and scalable server-side applications. Perfect for crafting enterprise-level APIs, microservices, and full-stack applications with TypeScript excellence.
6
7
 
7
- [![Version npm](https://img.shields.io/npm/v/koatty.svg?style=flat-square)](https://www.npmjs.com/package/koatty)[![npm Downloads](https://img.shields.io/npm/dm/koatty.svg?style=flat-square)](https://npmcharts.com/compare/koatty?minimal=true)
8
+ ## Why Koatty? 💡
8
9
 
9
- ## New features
10
+ - 🚄 **High Performance**: Built on top of Koa2 with optimized architecture
11
+ - 🧩 **Full-Featured**: Supports gRPC, HTTP, WebSocket, Schedule tasks, and more
12
+ - 🧠 **TypeScript First**: Native TypeScript support with elegant OOP design
13
+ - 🌀 **Spring-like IOC Container**: Powerful dependency injection system with autowiring
14
+ - ✂️ **AOP Support**: Aspect-oriented programming with decorator-based interceptors
15
+ - 🔌 **Extensible Architecture**: Plugin system with dependency injection
16
+ - 📦 **Modern Tooling**: CLI scaffolding, testing utilities, and production-ready configs
17
+ - 🌐 **Protocol Agnostic**: Write once, deploy as HTTP/gRPC/WebSocket services
18
+
19
+
20
+ ## New features ✨
10
21
 
11
22
  * HTTP、HTTPS、HTTP2、gRPC、WebSocket server.✔️
12
- * Support loading environment configuration, parsing command line parameters (process.argv) and environment variables (process.env).✔️
23
+ * Support loading configurations based on the environment, support command-line argument parsing(process.argv), and support environment variable parsing(process.env).✔️
13
24
  * `@ExceptionHandler()` Register global exception handling.✔️
14
- * graceful shutdown and pre-exit event.✔️
15
- * custom decorator based on app events.✔️
16
- * GraphQL supporting. 💪
25
+ * Graceful shutdown and pre-exit event.✔️
26
+ * Supports custom decorators, bound to app events for execution.✔️
27
+ * GraphQL supporting. ✔️
17
28
  * OpenTelemetry . 💪
18
29
 
19
30
 
20
- ## Documentation
21
-
22
- [koatty_doc_CN](https://koatty.org/) (In progress💪)
31
+ ## Core Features ✨
23
32
 
24
-
25
- ## Installation CLI tools
26
-
27
- ```shell
28
- npm i -g koatty_cli
33
+ ### 📡 Multi-Protocol Support
34
+ ```typescript
35
+ // config/config.ts
36
+ export default {
37
+ ...
38
+ protocol: "grpc", // Server protocol 'http' | 'https' | 'http2' | 'grpc' | 'ws' | 'wss'
39
+ ...
40
+ }
29
41
  ```
30
42
 
31
- ## Quick Start
43
+ ### 💉 Dependency Injection
44
+ ```typescript
45
+ @Service()
46
+ export class UserService {
47
+ async findUser(id: number) {
48
+ return { id, name: 'Koatty User' };
49
+ }
50
+ }
32
51
 
33
- ### 1.Create Project
52
+ @Controller()
53
+ export class IndexController {
54
+ app: App;
55
+ ctx: KoattyContext;
56
+ ...
34
57
 
35
- ```shell
36
- kt new projectName
58
+ @Autowired()
59
+ private userService: UserService;
37
60
 
61
+ async test(id: number) {
62
+ const info = await this.userService.findUser(id);
63
+ ...
64
+ }
65
+ }
38
66
  ```
39
67
 
40
- ### 2. Install deps
68
+ ### ✂️ Aspect-Oriented Programming
69
+ ```javascript
70
+ @Aspect()
71
+ export class LogAspect implements IAspect {
72
+ app: App;
41
73
 
42
- ```
43
- cd ./projectName
74
+ run() {
75
+ console.log('LogAspect');
76
+ }
77
+ }
44
78
 
45
- npm i
79
+ // Apply aspect to controller
80
+ @Controller()
81
+ @BeforeEach(LogAspect)
82
+ export class UserController {}
46
83
  ```
47
84
 
48
- ### 3. Start up
49
-
85
+ ### 🔌 Plugin System
86
+ ```javascript
87
+ // plugin/logger.ts
88
+ export class LoggerPlugin implements IPlugin {
89
+ app: App;
90
+
91
+ run() {
92
+ // todo something or hook on app.event
93
+ Logger.Debug("LoggerPlugin");
94
+ return Promise.resolve();
95
+ }
96
+ }
50
97
  ```
51
- npm run dev
52
98
 
53
- // or
54
- npm start
55
- ```
56
99
 
57
- ## Code style
100
+ ## Benchmarks 📊
58
101
 
59
- default Controller:
102
+ | Framework | Requests/sec | Latency | Memory Usage |
103
+ | ---------- | ------------ | ------- | ------------ |
104
+ | **Koatty** | 13,321 | 1.43ms | 54MB |
105
+ | Express | 12,456 | 1.45ms | 52MB |
106
+ | NestJS | 11,892 | 1.51ms | 63MB |
60
107
 
61
- ```javascript
62
- import { Controller, Autowired, GetMapping, RequestBody, PathVariable,
63
- PostMapping, RequestMapping, RequestMethod, Valid, Output } from "koatty";
64
- import { TestDTO } from "../model/dto/TestDTO";
65
- import { TestService } from "../service/TestService";
66
- import { App } from "../App";
108
+ *Tested on AWS t3.micro with 100 concurrent connections*
67
109
 
68
- @Controller()
69
- export class IndexController {
70
- app: App;
71
- ctx: KoattyContext;
110
+ ## Documentation 📚
72
111
 
73
- @Autowired()
74
- private testService: TestService;
75
-
76
- /**
77
- * constructor
78
- *
79
- */
80
- constructor(ctx: KoattyContext) {
81
- this.ctx = ctx;
82
- }
112
+ - [中文文档](https://koatty.org/)
113
+ - [Getting Started Guide](https://github.com/Koatty/koatty_doc/blob/master/docs/README-en.md)
114
+ - [API Reference](https://koatty.org/#/?id=api)
115
+ - [Recipes & Best Practices](https://github.com/Koatty/koatty_awesome)
116
+ - [Example](https://github.com/Koatty/koatty_demo)
83
117
 
84
- @GetMapping('/')
85
- index() {
86
- return Output.ok("Hello, koatty!");
87
- }
88
118
 
89
- @RequestMapping("/:name", RequestMethod.ALL)
90
- async default(@PathVariable("name") @Valid("IsNotEmpty") name: string) {
91
- try {
92
- const info = await this.testService.sayHello(name);
93
- return Output.ok(this.ctx, "success", info);
94
- } catch (err: Error) {
95
- return Output.fail(this.ctx, err.message));
96
- }
97
- }
119
+ ## Quick Start ⚡
98
120
 
99
- @PostMapping("/test")
100
- @Validated() //need DTOClass
101
- test(@RequestParam() params: TestDTO) {
102
- return Output.ok(this.ctx, "test", params);
103
- }
104
- }
121
+ 1. **Install CLI**:
122
+ ```bash
123
+ npm install -g koatty_cli
105
124
  ```
106
125
 
107
- ## How to do Unit Testing
108
-
109
- >only support `jest` UT framework now
110
-
111
- ```javascript
112
- import request from 'supertest';
113
- import { ExecBootStrap } from 'koatty';
114
- import { App } from '../src/App';
115
-
116
- describe('UT example', () => {
117
-
118
- let app: KoattyApplication;
119
- beforeAll(async () => {
120
- jest.useFakeTimers();
121
- // test env
122
- process.env.KOATTY_ENV = 'ts-node';
123
- app = await ExecBootStrap()(App);
124
- // app.use(async (ctx: any) => {
125
- // ctx.body = 'Hello, World!';
126
- // });
127
- });
128
-
129
- afterAll(done => {
130
- done();
131
- jest.clearAllMocks();
132
- });
133
-
134
- it('request', async () => {
135
- const res = await request(app.callback()).get('/');
136
- expect(res.status).toBe(200);
137
- });
138
- });
126
+ 2. **Create Project**:
127
+ ```bash
128
+ koatty new awesome-app
129
+ ```
139
130
 
131
+ 3. **Run Development Server**:
132
+ ```bash
133
+ cd awesome-app
134
+ npm run dev
140
135
  ```
141
136
 
142
- ## How to debug
143
137
 
144
- if you use vscode , edit the `.vscode/launch.json` , like this:
145
- ```
146
- {
147
- "version": "0.2.0",
148
- "configurations": [
149
- {
150
- "type": "node",
151
- "request": "launch",
152
- "name": "TS Program",
153
- "args": [
154
- "${workspaceRoot}/src/App.ts"
155
- ],
156
- "runtimeArgs": [
157
- "--nolazy",
158
- "-r",
159
- "ts-node/register"
160
- ],
161
- "sourceMaps": true,
162
- "cwd": "${workspaceRoot}",
163
- "protocol": "inspector",
164
- "outputCapture": "std",
165
- "internalConsoleOptions": "neverOpen"
166
- }
167
- ]
168
- }
169
- ```
170
- Select `TS Program` to debug run. Try to call `http://localhost:3000/` .
138
+ ## Community 🌍
139
+
140
+ - [GitHub Discussions](https://github.com/Koatty/koatty/discussions)
171
141
 
172
- ## Example
142
+ ## Contributors ✨
173
143
 
174
- Check out the [quick start example][quick-example].
144
+ Thanks to these amazing developers:
175
145
 
176
- [quick-example]: https://github.com/Koatty/koatty_template
146
+ <!-- Add contributor list here -->
177
147
 
178
148
 
149
+ ## License 📄
179
150
 
151
+ BSD-3 © [Koatty Team](https://github.com/Koatty)
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2025-01-14 16:20:30
3
+ * @Date: 2025-03-15 23:04:27
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2025-01-14 16:20:07
3
+ * @Date: 2025-03-15 23:04:17
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
@@ -37,7 +37,7 @@ function _interopNamespaceDefault(e) {
37
37
 
38
38
  var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
39
39
 
40
- var version = "3.11.9";
40
+ var version = "3.12.0";
41
41
  var engines = {
42
42
  node: ">12.0.0"
43
43
  };
@@ -182,7 +182,7 @@ https://github.com/koatty
182
182
  * @Usage:
183
183
  * @Author: richen
184
184
  * @Date: 2023-12-09 22:55:49
185
- * @LastEditTime: 2025-01-14 16:12:59
185
+ * @LastEditTime: 2025-03-13 16:44:39
186
186
  * @License: BSD (3-Clause)
187
187
  * @Copyright (c): <richenlin(at)gmail.com>
188
188
  */
@@ -390,15 +390,16 @@ class Loader {
390
390
  const loader = new Loader(app);
391
391
  loader.LoadConfigs(configurationMeta);
392
392
  // Create Server
393
+ const protocol = app.config('protocol');
393
394
  const serveOpts = {
394
395
  hostname: app.config('app_host'),
395
396
  port: app.config('app_port'),
396
- protocol: app.config('protocol'),
397
+ protocol: protocol,
397
398
  };
398
399
  koatty_lib.Helper.define(app, "server", koatty_serve.NewServe(app, serveOpts));
399
- // Create router
400
+ // Create router
400
401
  const routerOpts = (_a = app.config(undefined, 'router')) !== null && _a !== void 0 ? _a : {};
401
- koatty_lib.Helper.define(app, "router", koatty_router.NewRouter(app, routerOpts));
402
+ koatty_lib.Helper.define(app, "router", koatty_router.NewRouter(app, { protocol, ...routerOpts }));
402
403
  // Load Components
403
404
  Logger.Log('Koatty', '', 'Load Components ...');
404
405
  await loader.LoadComponents();
@@ -477,12 +478,13 @@ class Loader {
477
478
  if (!koatty_lib.Helper.isFunction(handle.run)) {
478
479
  throw Error(`The middleware ${key} must implements interface 'IMiddleware'.`);
479
480
  }
480
- if (middlewareConfig[key] === false) {
481
- Logger.Warn(`The middleware ${key} has been loaded but not executed.`);
482
- continue;
483
- }
481
+ // if (middlewareConfig[key] === false) {
482
+ // Logger.Warn(`The middleware ${key} has been loaded but not executed.`);
483
+ // continue;
484
+ // }
484
485
  Logger.Debug(`Load middleware: ${key}`);
485
- const result = await handle.run(middlewareConfig[key] || {}, this.app);
486
+ const middlewareOpt = middlewareConfig[key] || {};
487
+ const result = await handle.run(middlewareOpt, this.app);
486
488
  if (koatty_lib.Helper.isFunction(result)) {
487
489
  if (result.length < 3) {
488
490
  this.app.use(result);
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2025-01-14 16:20:07
3
+ * @Date: 2025-03-15 23:04:17
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
@@ -21,7 +21,7 @@ import { Load } from 'koatty_loader';
21
21
  import { NewServe } from 'koatty_serve';
22
22
  import * as path from 'path';
23
23
 
24
- var version = "3.11.9";
24
+ var version = "3.12.0";
25
25
  var engines = {
26
26
  node: ">12.0.0"
27
27
  };
@@ -166,7 +166,7 @@ https://github.com/koatty
166
166
  * @Usage:
167
167
  * @Author: richen
168
168
  * @Date: 2023-12-09 22:55:49
169
- * @LastEditTime: 2025-01-14 16:12:59
169
+ * @LastEditTime: 2025-03-13 16:44:39
170
170
  * @License: BSD (3-Clause)
171
171
  * @Copyright (c): <richenlin(at)gmail.com>
172
172
  */
@@ -374,15 +374,16 @@ class Loader {
374
374
  const loader = new Loader(app);
375
375
  loader.LoadConfigs(configurationMeta);
376
376
  // Create Server
377
+ const protocol = app.config('protocol');
377
378
  const serveOpts = {
378
379
  hostname: app.config('app_host'),
379
380
  port: app.config('app_port'),
380
- protocol: app.config('protocol'),
381
+ protocol: protocol,
381
382
  };
382
383
  Helper.define(app, "server", NewServe(app, serveOpts));
383
- // Create router
384
+ // Create router
384
385
  const routerOpts = (_a = app.config(undefined, 'router')) !== null && _a !== void 0 ? _a : {};
385
- Helper.define(app, "router", NewRouter(app, routerOpts));
386
+ Helper.define(app, "router", NewRouter(app, { protocol, ...routerOpts }));
386
387
  // Load Components
387
388
  Logger.Log('Koatty', '', 'Load Components ...');
388
389
  await loader.LoadComponents();
@@ -461,12 +462,13 @@ class Loader {
461
462
  if (!Helper.isFunction(handle.run)) {
462
463
  throw Error(`The middleware ${key} must implements interface 'IMiddleware'.`);
463
464
  }
464
- if (middlewareConfig[key] === false) {
465
- Logger.Warn(`The middleware ${key} has been loaded but not executed.`);
466
- continue;
467
- }
465
+ // if (middlewareConfig[key] === false) {
466
+ // Logger.Warn(`The middleware ${key} has been loaded but not executed.`);
467
+ // continue;
468
+ // }
468
469
  Logger.Debug(`Load middleware: ${key}`);
469
- const result = await handle.run(middlewareConfig[key] || {}, this.app);
470
+ const middlewareOpt = middlewareConfig[key] || {};
471
+ const result = await handle.run(middlewareOpt, this.app);
470
472
  if (Helper.isFunction(result)) {
471
473
  if (result.length < 3) {
472
474
  this.app.use(result);
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koatty",
3
- "version": "3.11.9",
3
+ "version": "3.12.0",
4
4
  "description": "Koa2 + Typescript = koatty. Use Typescript's decorator implement auto injection.",
5
5
  "scripts": {
6
6
  "build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
@@ -9,7 +9,7 @@
9
9
  "build:doc": "npx api-documenter markdown --input temp --output docs/api",
10
10
  "build:dts": "npx tsc && npx api-extractor run --local --verbose",
11
11
  "eslint": "eslint --ext .ts,.js ./",
12
- "lock": "npx del-cli --force node_modules && npm i --package-lock-only && npm audit fix && npx pnpm i",
12
+ "lock": "npm i --package-lock-only && npm audit fix && npx pnpm i",
13
13
  "prepublishOnly": "npm test && npm run build && git push --follow-tags origin",
14
14
  "prerelease": "npm run lock && npm test && npm run build",
15
15
  "release": "standard-version",
@@ -60,6 +60,7 @@
60
60
  "@rollup/plugin-commonjs": "^28.x.x",
61
61
  "@rollup/plugin-json": "^6.x.x",
62
62
  "@rollup/plugin-node-resolve": "^15.x.x",
63
+ "@rollup/plugin-terser": "^0.x.x",
63
64
  "@types/formidable": "^3.x.x",
64
65
  "@types/jest": "^29.x.x",
65
66
  "@types/koa": "^2.x.x",
@@ -77,31 +78,30 @@
77
78
  "husky": "^4.x.x",
78
79
  "jest": "^29.x.x",
79
80
  "jest-html-reporters": "^3.x.x",
80
- "koatty_exception": "~1.5.3",
81
81
  "koatty_validation": "~1.x.x",
82
82
  "reflect-metadata": "^0.x.x",
83
83
  "rollup": "^4.x.x",
84
- "rollup-plugin-delete": "^2.1.0",
84
+ "rollup-plugin-delete": "^2.x.x",
85
85
  "rollup-plugin-typescript2": "^0.x.x",
86
86
  "standard-version": "^9.x.x",
87
- "supertest": "^7.0.0",
87
+ "supertest": "^7.x.x",
88
88
  "ts-jest": "^29.x.x",
89
89
  "ts-node": "^10.x.x",
90
90
  "tslib": "^2.x.x",
91
91
  "typescript": "^5.x.x"
92
92
  },
93
93
  "dependencies": {
94
- "koa": "~2.15.3",
94
+ "koa": "~2.16.0",
95
95
  "koatty_config": "~1.2.0",
96
- "koatty_container": "~1.9.4",
97
- "koatty_core": "~1.11.5",
96
+ "koatty_container": "~1.10.1",
97
+ "koatty_core": "~1.13.0",
98
98
  "koatty_exception": "~1.5.3",
99
99
  "koatty_lib": "~1.4.0",
100
100
  "koatty_loader": "~1.1.0",
101
101
  "koatty_logger": "~2.1.8",
102
- "koatty_proto": "~1.2.0",
103
- "koatty_router": "~1.10.1",
102
+ "koatty_router": "~1.14.1",
104
103
  "koatty_serve": "~2.3.0",
105
- "koatty_trace": "~1.13.1"
104
+ "koatty_trace": "~1.13.1",
105
+ "ts-morph": "^25.0.1"
106
106
  }
107
107
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koatty",
3
- "version": "3.11.9",
3
+ "version": "3.12.0",
4
4
  "description": "Koa2 + Typescript = koatty. Use Typescript's decorator implement auto injection.",
5
5
  "scripts": {
6
6
  "build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
@@ -9,7 +9,7 @@
9
9
  "build:doc": "npx api-documenter markdown --input temp --output docs/api",
10
10
  "build:dts": "npx tsc && npx api-extractor run --local --verbose",
11
11
  "eslint": "eslint --ext .ts,.js ./",
12
- "lock": "npx del-cli --force node_modules && npm i --package-lock-only && npm audit fix && npx pnpm i",
12
+ "lock": "npm i --package-lock-only && npm audit fix && npx pnpm i",
13
13
  "prepublishOnly": "npm test && npm run build && git push --follow-tags origin",
14
14
  "prerelease": "npm run lock && npm test && npm run build",
15
15
  "release": "standard-version",
@@ -60,6 +60,7 @@
60
60
  "@rollup/plugin-commonjs": "^28.x.x",
61
61
  "@rollup/plugin-json": "^6.x.x",
62
62
  "@rollup/plugin-node-resolve": "^15.x.x",
63
+ "@rollup/plugin-terser": "^0.x.x",
63
64
  "@types/formidable": "^3.x.x",
64
65
  "@types/jest": "^29.x.x",
65
66
  "@types/koa": "^2.x.x",
@@ -77,31 +78,30 @@
77
78
  "husky": "^4.x.x",
78
79
  "jest": "^29.x.x",
79
80
  "jest-html-reporters": "^3.x.x",
80
- "koatty_exception": "~1.5.3",
81
81
  "koatty_validation": "~1.x.x",
82
82
  "reflect-metadata": "^0.x.x",
83
83
  "rollup": "^4.x.x",
84
- "rollup-plugin-delete": "^2.1.0",
84
+ "rollup-plugin-delete": "^2.x.x",
85
85
  "rollup-plugin-typescript2": "^0.x.x",
86
86
  "standard-version": "^9.x.x",
87
- "supertest": "^7.0.0",
87
+ "supertest": "^7.x.x",
88
88
  "ts-jest": "^29.x.x",
89
89
  "ts-node": "^10.x.x",
90
90
  "tslib": "^2.x.x",
91
91
  "typescript": "^5.x.x"
92
92
  },
93
93
  "dependencies": {
94
- "koa": "~2.15.3",
94
+ "koa": "~2.16.0",
95
95
  "koatty_config": "~1.2.0",
96
- "koatty_container": "~1.9.4",
97
- "koatty_core": "~1.11.5",
96
+ "koatty_container": "~1.10.1",
97
+ "koatty_core": "~1.13.0",
98
98
  "koatty_exception": "~1.5.3",
99
99
  "koatty_lib": "~1.4.0",
100
100
  "koatty_loader": "~1.1.0",
101
101
  "koatty_logger": "~2.1.8",
102
- "koatty_proto": "~1.2.0",
103
- "koatty_router": "~1.10.1",
102
+ "koatty_router": "~1.14.1",
104
103
  "koatty_serve": "~2.3.0",
105
- "koatty_trace": "~1.13.1"
104
+ "koatty_trace": "~1.13.1",
105
+ "ts-morph": "^25.0.1"
106
106
  }
107
107
  }