koa-ts-core 0.0.4 → 0.0.6

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.
@@ -4,5 +4,5 @@ import Koa from "koa";
4
4
  * @param app - Koa 应用实例
5
5
  * @returns - 可用的端口号
6
6
  */
7
- declare const initializeServer: (app: Koa) => Promise<number>;
7
+ declare const initializeServer: (app: Koa) => Promise<void>;
8
8
  export default initializeServer;
@@ -0,0 +1,7 @@
1
+ import { Middleware } from "koa";
2
+ /**
3
+ * 往global添加属性
4
+ * @param ctx
5
+ */
6
+ declare const requestParamsMiddleware: Middleware;
7
+ export default requestParamsMiddleware;
@@ -0,0 +1,16 @@
1
+ export interface IMetaData {
2
+ method: string;
3
+ description: string;
4
+ path: string;
5
+ request: Request;
6
+ response: Response;
7
+ }
8
+ interface Response {
9
+ body: any;
10
+ }
11
+ interface Request {
12
+ header: Record<string, string>;
13
+ body: any;
14
+ query: any;
15
+ }
16
+ export {};
@@ -22,4 +22,5 @@ export interface RouteConfig {
22
22
  authRequired: boolean;
23
23
  middlewares: Middleware[];
24
24
  className: string;
25
+ apiPrePath: string;
25
26
  }
@@ -22,12 +22,12 @@ export declare const getDefaultExportFromFile: <T = any>(filePath: string) => T
22
22
  */
23
23
  export declare function walkDirectorySync(currentDirPath: string, callback: WalkSyncHandler): void;
24
24
  /**
25
- * 根据路由器的路径生成控制器前缀和类名
25
+ * 根据文件路径和关键字部分生成路径的模块选项
26
26
  * @param {FilePathMeta} filePath - 文件路径元数据
27
27
  * @returns {Object} 包含控制器前缀、模块名和文件名的对象
28
28
  */
29
- export declare const generateControllerOptions: (filePath: FilePathMeta) => {
30
- controllerPrefix: string;
29
+ export declare const generateOptionsByKeyPart: (filePath: FilePathMeta, keyPart: string) => {
30
+ pathPrefix: string;
31
31
  moduleName: string;
32
32
  name: string;
33
33
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koa-ts-core",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "koa-ts-core",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -13,7 +13,7 @@
13
13
  "build": "npx rollup -c",
14
14
  "link": "npm run build:dev && pnpm link --dir ..",
15
15
  "build:dev": "NODE_ENV=development npx rollup -c --bundleConfigAsCjs",
16
- "publish": "npm run build &&release-it",
16
+ "publish": "npm run build && release-it",
17
17
  "gen-doc": "npx ts-node src/generate.ts"
18
18
  },
19
19
  "keywords": [
@@ -26,16 +26,21 @@
26
26
  "dependencies": {
27
27
  "dotenv": "^16.4.7",
28
28
  "koa": "^2.15.4",
29
+ "koa-bodyparser": "^4.4.1",
29
30
  "koa-router": "^13.0.1",
31
+ "koa-ts-core": "link:",
32
+ "portfinder": "^1.0.37",
30
33
  "pug": "^3.0.3",
31
34
  "rollup-plugin-pug": "^1.1.1"
32
35
  },
33
36
  "devDependencies": {
34
37
  "@rollup/plugin-commonjs": "^28.0.3",
38
+ "@rollup/plugin-json": "^6.1.0",
35
39
  "@rollup/plugin-node-resolve": "^16.0.0",
36
40
  "@rollup/plugin-terser": "^0.4.4",
37
41
  "@rollup/plugin-typescript": "^12.1.2",
38
42
  "@types/koa": "^2.15.0",
43
+ "@types/koa-bodyparser": "^4.3.12",
39
44
  "@types/koa-router": "^7.4.8",
40
45
  "@types/node": "^22.13.4",
41
46
  "@types/pug": "^2.0.10",
@@ -1,13 +0,0 @@
1
- /**
2
- * 检查端口是否可用
3
- * @param {number} port - 要检查的端口号
4
- * @returns {Promise<boolean>} - 如果端口可用,则返回 true;否则返回 false
5
- */
6
- declare const isPortAvailable: (port: number) => Promise<boolean>;
7
- /**
8
- * 找到可用的端口,默认从指定的起始端口开始检查
9
- * @param {number} startPort - 起始检查的端口号,默认为 8000
10
- * @returns {Promise<number>} - 返回第一个可用的端口
11
- */
12
- declare const findAvailablePort: (startPort?: number, maxPort?: number) => Promise<number>;
13
- export { isPortAvailable, findAvailablePort };