streamline-code-by-ikun2274 0.12.2 → 0.12.4

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 (2) hide show
  1. package/package.json +2 -1
  2. package/types/index.d.ts +31 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "streamline-code-by-ikun2274",
3
- "version": "0.12.2",
3
+ "version": "0.12.4",
4
4
  "description": "A streamline Express route builder with database operations, pagination, and authentication",
5
5
  "main": "src/StreamlineCodeIndex.js",
6
6
  "exports": {
@@ -10,6 +10,7 @@
10
10
 
11
11
  }
12
12
  },
13
+ "types": "./types/index.d.ts",
13
14
  "scripts": {
14
15
 
15
16
  },
package/types/index.d.ts CHANGED
@@ -150,6 +150,26 @@ export interface ToolDb {
150
150
  * @param {string} [options.PlusHandler.other.errorMessage='操作失败'] - 错误消息(可选)
151
151
  *
152
152
  */
153
+ /**
154
+ * 二次封装 defineRoute 函数
155
+ * @param options 路由配置选项
156
+ * @param options.url 路由路径(必填)
157
+ * @param options.method HTTP 方法(GET/POST/PUT/DELETE,必填)
158
+ * @param options.middlewares 中间件数组(可选 用户自定义中间件)
159
+ * @param options.BuiltinMid 内置中间件配置,填一个激活一个
160
+ * @param options.autoGenerateId 自动生成 ID,默认为 false
161
+ * @param options.PlusHandler 额外处理选项(必填)
162
+ * @param options.PlusHandler.db 数据库操作(必填)
163
+ * @param options.PlusHandler.db.table 数据库表名(必填)
164
+ * @param options.PlusHandler.db.operation 数据表操作(必填)select/insert/update/delete
165
+ * @param options.PlusHandler.db.primaryKey 主键字段,默认为 'id'
166
+ * @param options.PlusHandler.db.fields 查询字段,默认为 '*'
167
+ * @param options.PlusHandler.db.categoryField 分类字段,默认为 'category_id'
168
+ * @param options.PlusHandler.other 其他选项(必填)
169
+ * @param options.PlusHandler.other.customLogic 自定义逻辑函数
170
+ * @param options.PlusHandler.other.successMessage 成功消息,默认为 '操作成功'
171
+ * @param options.PlusHandler.other.errorMessage 错误消息,默认为 '操作失败'
172
+ */
153
173
  export function DefineRoutePlus_A(options: RouteConfig): void;
154
174
 
155
175
  /**
@@ -182,6 +202,17 @@ export function setDbConfig(config: Partial<DbConfig>): void;
182
202
  */
183
203
  export function query(sql: string, params?: any[]): Promise<any>;
184
204
 
205
+ /**
206
+ * 启动服务器
207
+ * @param options 配置选项
208
+ * @param options.port 服务器端口,默认3001
209
+ * @param options.allowedOrigins 允许的域名列表
210
+ */
211
+ export function startServer(options?: {
212
+ port?: number;
213
+ allowedOrigins?: string[];
214
+ }): void;
215
+
185
216
  /**
186
217
  * Express 应用实例
187
218
  */