@lark-apaas/devtool-kits 1.2.17-alpha.17 → 1.2.17-alpha.18

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/dist/index.d.cts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { IncomingMessage, ServerResponse } from 'node:http';
2
2
  import { Router, RequestHandler, Application } from 'express';
3
+ import { ServerResponse as ServerResponse$1, IncomingMessage as IncomingMessage$1 } from 'http';
3
4
 
4
5
  /**
5
6
  * 标准化基础路径,确保以 '/' 开头且不包含 trailing slash
@@ -197,12 +198,39 @@ interface DevLogsMiddlewareOptions {
197
198
  declare function createCollectLogsMiddleware(options?: DevLogsMiddlewareOptions): RouteMiddleware;
198
199
 
199
200
  /**
200
- * Creates api-routes middleware for listing application API routes
201
- * Used by the API Debug Panel in the platform
202
- *
203
- * Note: Temporarily mounted at /dev/logs for debugging. Will move to dedicated path after confirming it works.
201
+ * Express/Connect 兼容层
202
+ * middleware 同时支持 Express Vite/Connect
203
+ */
204
+
205
+ type AnyResponse = ServerResponse$1 & {
206
+ status?: (code: number) => AnyResponse;
207
+ json?: (data: unknown) => void;
208
+ send?: (data: unknown) => void;
209
+ };
210
+ type AnyRequest = IncomingMessage$1 & {
211
+ query?: Record<string, string>;
212
+ params?: Record<string, string>;
213
+ };
214
+ /**
215
+ * 发送 JSON 响应,兼容 Express 和 Connect
216
+ */
217
+ declare function sendJson(res: AnyResponse, data: unknown, statusCode?: number): void;
218
+ /**
219
+ * 发送错误响应
220
+ */
221
+ declare function sendError(res: AnyResponse, message: string, error?: unknown, statusCode?: number): void;
222
+ /**
223
+ * 发送成功响应
224
+ */
225
+ declare function sendSuccess(res: AnyResponse, data?: Record<string, unknown>): void;
226
+ /**
227
+ * 获取 query 参数,兼容 Express 和 Connect
228
+ */
229
+ declare function getQuery(req: AnyRequest): Record<string, string>;
230
+ /**
231
+ * 获取单个 query 参数
204
232
  */
205
- declare function createApiRoutesMiddleware(): RouteMiddleware;
233
+ declare function getQueryParam(req: AnyRequest, key: string): string | undefined;
206
234
 
207
235
  /**
208
236
  * Register middlewares for Express-compatible servers or Vite
@@ -243,4 +271,4 @@ declare function createApiRoutesMiddleware(): RouteMiddleware;
243
271
  */
244
272
  declare function registerMiddlewares(server: ExpressApp | ViteMiddleware, middlewares: Middleware[], options?: Partial<MiddlewareContext>): Promise<void>;
245
273
 
246
- export { type GlobalMiddleware, type Middleware, type MiddlewareContext, type Options, type RouteInfo, type RouteMiddleware, createApiRoutesMiddleware, createCollectLogsMiddleware, createDevLogsMiddleware, createOpenapiMiddleware, handleDevProxyError, normalizeBasePath, parseAndGenerateNestResourceTemplate, postprocessDrizzleSchema, registerMiddlewares };
274
+ export { type GlobalMiddleware, type Middleware, type MiddlewareContext, type Options, type RouteInfo, type RouteMiddleware, createCollectLogsMiddleware, createDevLogsMiddleware, createOpenapiMiddleware, getQuery, getQueryParam, handleDevProxyError, normalizeBasePath, parseAndGenerateNestResourceTemplate, postprocessDrizzleSchema, registerMiddlewares, sendError, sendJson, sendSuccess };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { IncomingMessage, ServerResponse } from 'node:http';
2
2
  import { Router, RequestHandler, Application } from 'express';
3
+ import { ServerResponse as ServerResponse$1, IncomingMessage as IncomingMessage$1 } from 'http';
3
4
 
4
5
  /**
5
6
  * 标准化基础路径,确保以 '/' 开头且不包含 trailing slash
@@ -197,12 +198,39 @@ interface DevLogsMiddlewareOptions {
197
198
  declare function createCollectLogsMiddleware(options?: DevLogsMiddlewareOptions): RouteMiddleware;
198
199
 
199
200
  /**
200
- * Creates api-routes middleware for listing application API routes
201
- * Used by the API Debug Panel in the platform
202
- *
203
- * Note: Temporarily mounted at /dev/logs for debugging. Will move to dedicated path after confirming it works.
201
+ * Express/Connect 兼容层
202
+ * middleware 同时支持 Express Vite/Connect
203
+ */
204
+
205
+ type AnyResponse = ServerResponse$1 & {
206
+ status?: (code: number) => AnyResponse;
207
+ json?: (data: unknown) => void;
208
+ send?: (data: unknown) => void;
209
+ };
210
+ type AnyRequest = IncomingMessage$1 & {
211
+ query?: Record<string, string>;
212
+ params?: Record<string, string>;
213
+ };
214
+ /**
215
+ * 发送 JSON 响应,兼容 Express 和 Connect
216
+ */
217
+ declare function sendJson(res: AnyResponse, data: unknown, statusCode?: number): void;
218
+ /**
219
+ * 发送错误响应
220
+ */
221
+ declare function sendError(res: AnyResponse, message: string, error?: unknown, statusCode?: number): void;
222
+ /**
223
+ * 发送成功响应
224
+ */
225
+ declare function sendSuccess(res: AnyResponse, data?: Record<string, unknown>): void;
226
+ /**
227
+ * 获取 query 参数,兼容 Express 和 Connect
228
+ */
229
+ declare function getQuery(req: AnyRequest): Record<string, string>;
230
+ /**
231
+ * 获取单个 query 参数
204
232
  */
205
- declare function createApiRoutesMiddleware(): RouteMiddleware;
233
+ declare function getQueryParam(req: AnyRequest, key: string): string | undefined;
206
234
 
207
235
  /**
208
236
  * Register middlewares for Express-compatible servers or Vite
@@ -243,4 +271,4 @@ declare function createApiRoutesMiddleware(): RouteMiddleware;
243
271
  */
244
272
  declare function registerMiddlewares(server: ExpressApp | ViteMiddleware, middlewares: Middleware[], options?: Partial<MiddlewareContext>): Promise<void>;
245
273
 
246
- export { type GlobalMiddleware, type Middleware, type MiddlewareContext, type Options, type RouteInfo, type RouteMiddleware, createApiRoutesMiddleware, createCollectLogsMiddleware, createDevLogsMiddleware, createOpenapiMiddleware, handleDevProxyError, normalizeBasePath, parseAndGenerateNestResourceTemplate, postprocessDrizzleSchema, registerMiddlewares };
274
+ export { type GlobalMiddleware, type Middleware, type MiddlewareContext, type Options, type RouteInfo, type RouteMiddleware, createCollectLogsMiddleware, createDevLogsMiddleware, createOpenapiMiddleware, getQuery, getQueryParam, handleDevProxyError, normalizeBasePath, parseAndGenerateNestResourceTemplate, postprocessDrizzleSchema, registerMiddlewares, sendError, sendJson, sendSuccess };
package/dist/index.js CHANGED
@@ -1605,7 +1605,7 @@ function createOpenapiRouter(options, context) {
1605
1605
  const { openapiFilePath, enableEnhancement, serverDir } = options;
1606
1606
  const router = express.Router();
1607
1607
  const handler = createOpenapiHandler(openapiFilePath, enableEnhancement, serverDir);
1608
- router.get("/", (req, res) => handler(req, res, context));
1608
+ router.get("/openapi.json", (req, res) => handler(req, res, context));
1609
1609
  return router;
1610
1610
  }
1611
1611
  __name(createOpenapiRouter, "createOpenapiRouter");
@@ -1614,7 +1614,7 @@ __name(createOpenapiRouter, "createOpenapiRouter");
1614
1614
  var OPENAPI_ROUTES = [
1615
1615
  {
1616
1616
  method: "GET",
1617
- path: "/",
1617
+ path: "/openapi.json",
1618
1618
  description: "Serve enhanced OpenAPI specification with source code references"
1619
1619
  }
1620
1620
  ];
@@ -1622,7 +1622,7 @@ function createOpenapiMiddleware(options) {
1622
1622
  const { openapiFilePath, enableEnhancement = true, serverDir } = options;
1623
1623
  return {
1624
1624
  name: "openapi",
1625
- mountPath: "/dev/openapi.json",
1625
+ mountPath: "/dev",
1626
1626
  routes: OPENAPI_ROUTES,
1627
1627
  enabled: /* @__PURE__ */ __name((context) => context.isDev, "enabled"),
1628
1628
  createRouter: /* @__PURE__ */ __name((context) => {
@@ -1894,10 +1894,8 @@ function parsePinoLog(line, source) {
1894
1894
  statusCode: pinoLog.status_code,
1895
1895
  durationMs: pinoLog.duration_ms,
1896
1896
  ip: pinoLog.ip,
1897
- referer: pinoLog.referer,
1898
1897
  requestBody: pinoLog.request_body,
1899
- responseBody: pinoLog.response_body,
1900
- queryParams: pinoLog.query_params
1898
+ responseBody: pinoLog.response_body
1901
1899
  },
1902
1900
  tags: [
1903
1901
  source
@@ -2802,8 +2800,7 @@ function parsePinoLog2(line, source) {
2802
2800
  durationMs: pinoLog.duration_ms,
2803
2801
  ip: pinoLog.ip,
2804
2802
  requestBody: pinoLog.request_body,
2805
- responseBody: pinoLog.response_body,
2806
- queryParams: pinoLog.query_params
2803
+ responseBody: pinoLog.response_body
2807
2804
  },
2808
2805
  tags: [
2809
2806
  source
@@ -3254,108 +3251,6 @@ function createSSEHandler(logDir, options = {}) {
3254
3251
  }
3255
3252
  __name(createSSEHandler, "createSSEHandler");
3256
3253
 
3257
- // src/middlewares/dev-logs/api-list-handler.ts
3258
- var SERVER_PORT = process.env.SERVER_PORT || "3000";
3259
- function extractModuleFromPath(path7) {
3260
- const segments = path7.split("/").filter(Boolean);
3261
- let startIndex = 0;
3262
- if (segments[0] === "api") {
3263
- startIndex = 1;
3264
- }
3265
- if (segments[startIndex]?.match(/^v\d+$/)) {
3266
- startIndex++;
3267
- }
3268
- const moduleName = segments[startIndex];
3269
- if (!moduleName || moduleName.startsWith(":")) {
3270
- return "default";
3271
- }
3272
- return moduleName;
3273
- }
3274
- __name(extractModuleFromPath, "extractModuleFromPath");
3275
- function generateRouteId(method, path7) {
3276
- const cleanPath = path7.replace(/[/:]/g, "_").replace(/^_+|_+$/g, "");
3277
- return `${method.toLowerCase()}_${cleanPath}`;
3278
- }
3279
- __name(generateRouteId, "generateRouteId");
3280
- function capitalize(str) {
3281
- return str.charAt(0).toUpperCase() + str.slice(1);
3282
- }
3283
- __name(capitalize, "capitalize");
3284
- function groupRoutesByModule(routes) {
3285
- const groupMap = /* @__PURE__ */ new Map();
3286
- routes.forEach((route) => {
3287
- const existing = groupMap.get(route.module) || [];
3288
- existing.push(route);
3289
- groupMap.set(route.module, existing);
3290
- });
3291
- const groups = [];
3292
- groupMap.forEach((apis, moduleName) => {
3293
- groups.push({
3294
- id: moduleName,
3295
- name: capitalize(moduleName),
3296
- apis: apis.sort((a, b) => a.path.localeCompare(b.path))
3297
- });
3298
- });
3299
- return groups.sort((a, b) => a.name.localeCompare(b.name));
3300
- }
3301
- __name(groupRoutesByModule, "groupRoutesByModule");
3302
- async function fetchRoutesFromBackend(basePath) {
3303
- const normalizedBasePath = basePath.replace(/\/+$/, "");
3304
- const url = `http://localhost:${SERVER_PORT}${normalizedBasePath}/api/__framework__/debug`;
3305
- const response = await fetch(url, {
3306
- method: "GET",
3307
- headers: {
3308
- "Accept": "application/json"
3309
- }
3310
- });
3311
- if (!response.ok) {
3312
- throw new Error(`Failed to fetch routes: ${response.status}`);
3313
- }
3314
- const data = await response.json();
3315
- const routeConfig = data["\u8DEF\u7531\u914D\u7F6E"];
3316
- if (!routeConfig || !routeConfig.routes) {
3317
- return [];
3318
- }
3319
- const debugRoutes = routeConfig.routes;
3320
- return debugRoutes.filter((route) => {
3321
- return route.path.includes("/api/") && !route.path.includes("__framework__") && !route.path.includes("__innerapi__") && !route.path.includes("/api/capability");
3322
- }).map((route) => {
3323
- const apiPathMatch = route.path.match(/\/api\/.*/);
3324
- const apiPath = apiPathMatch ? apiPathMatch[0] : route.path;
3325
- const method = route.method || "ALL";
3326
- return {
3327
- id: generateRouteId(method, apiPath),
3328
- path: apiPath,
3329
- method,
3330
- module: extractModuleFromPath(apiPath)
3331
- };
3332
- });
3333
- }
3334
- __name(fetchRoutesFromBackend, "fetchRoutesFromBackend");
3335
- function createApiListHandler() {
3336
- return async (req, res) => {
3337
- res.header("Access-Control-Allow-Origin", "*");
3338
- res.header("Access-Control-Allow-Methods", "GET, OPTIONS");
3339
- res.header("Access-Control-Allow-Headers", "Content-Type, Accept");
3340
- try {
3341
- const basePath = process.env.CLIENT_BASE_PATH || "";
3342
- const routes = await fetchRoutesFromBackend(basePath);
3343
- const groups = groupRoutesByModule(routes);
3344
- res.json({
3345
- groups,
3346
- total: routes.length
3347
- });
3348
- } catch (error) {
3349
- console.error("[api-list] Failed to fetch routes:", error);
3350
- res.status(500).json({
3351
- error: "Failed to fetch routes",
3352
- message: error instanceof Error ? error.message : "Unknown error"
3353
- });
3354
- }
3355
- };
3356
- }
3357
- __name(createApiListHandler, "createApiListHandler");
3358
-
3359
3254
  // src/middlewares/dev-logs/router.ts
3360
3255
  function createDevLogRouter(options = {}) {
3361
3256
  const logDir = resolveLogDir(options.logDir);
@@ -3369,7 +3264,6 @@ function createDevLogRouter(options = {}) {
3369
3264
  router.get("/trace/trigger/:instanceID", createGetTriggerDetailHandler(logDir));
3370
3265
  router.get("/trace/capability/list", createGetCapabilityTraceListHandler(logDir));
3371
3266
  router.get("/health", createHealthCheckHandler());
3372
- router.get("/api-list", createApiListHandler());
3373
3267
  return router;
3374
3268
  }
3375
3269
  __name(createDevLogRouter, "createDevLogRouter");
@@ -3405,11 +3299,6 @@ var DEV_LOGS_ROUTES = [
3405
3299
  method: "GET",
3406
3300
  path: "/trace/trigger/:instanceID",
3407
3301
  description: "Get trigger detail (automation trigger) in trace.log by instanceID"
3408
- },
3409
- {
3410
- method: "GET",
3411
- path: "/api-list",
3412
- description: "Get all API routes grouped by module"
3413
3302
  }
3414
3303
  ];
3415
3304
  function createDevLogsMiddleware(options = {}) {
@@ -3560,148 +3449,100 @@ function createCollectLogsMiddleware(options = {}) {
3560
3449
  }
3561
3450
  __name(createCollectLogsMiddleware, "createCollectLogsMiddleware");
3562
3451
 
3563
- // src/middlewares/api-routes/router.ts
3564
- import express4 from "express";
3565
- function extractModuleFromPath2(path7) {
3566
- const segments = path7.split("/").filter(Boolean);
3567
- let startIndex = 0;
3568
- if (segments[0] === "api") {
3569
- startIndex = 1;
3570
- }
3571
- if (segments[startIndex]?.match(/^v\d+$/)) {
3572
- startIndex++;
3573
- }
3574
- const moduleName = segments[startIndex];
3575
- if (!moduleName || moduleName.startsWith(":")) {
3576
- return "default";
3577
- }
3578
- return moduleName;
3579
- }
3580
- __name(extractModuleFromPath2, "extractModuleFromPath");
3581
- function generateRouteId2(method, path7) {
3582
- const cleanPath = path7.replace(/[/:]/g, "_").replace(/^_+|_+$/g, "");
3583
- return `${method.toLowerCase()}_${cleanPath}`;
3584
- }
3585
- __name(generateRouteId2, "generateRouteId");
3586
- function capitalize2(str) {
3587
- return str.charAt(0).toUpperCase() + str.slice(1);
3588
- }
3589
- __name(capitalize2, "capitalize");
3590
- function extractRoutes(app) {
3591
- const router = app._router;
3592
- if (!router?.stack) {
3593
- return [];
3452
+ // src/middlewares/compat.ts
3453
+ function sendJson(res, data, statusCode = 200) {
3454
+ const statusFn = res.status;
3455
+ const jsonFn = res.json;
3456
+ if (typeof statusFn === "function" && typeof jsonFn === "function") {
3457
+ statusFn.call(res, statusCode);
3458
+ jsonFn.call(res, data);
3459
+ } else {
3460
+ res.statusCode = statusCode;
3461
+ res.setHeader("Content-Type", "application/json");
3462
+ res.end(JSON.stringify(data));
3594
3463
  }
3595
- const routes = [];
3596
- const seenRoutes = /* @__PURE__ */ new Set();
3597
- const processLayer = /* @__PURE__ */ __name((layer, basePath = "") => {
3598
- if (layer.route) {
3599
- const path7 = basePath + layer.route.path;
3600
- if (!path7.includes("/api/") || path7.includes("__framework__") || path7.includes("__innerapi__")) {
3601
- return;
3602
- }
3603
- const methods = Object.keys(layer.route.methods).filter((m) => layer.route.methods[m]);
3604
- methods.forEach((method) => {
3605
- const upperMethod = method.toUpperCase();
3606
- const routeKey = `${upperMethod}:${path7}`;
3607
- if (seenRoutes.has(routeKey)) {
3608
- return;
3609
- }
3610
- seenRoutes.add(routeKey);
3611
- const apiPathMatch = path7.match(/\/api\/.*/);
3612
- const apiPath = apiPathMatch ? apiPathMatch[0] : path7;
3613
- routes.push({
3614
- id: generateRouteId2(upperMethod, apiPath),
3615
- path: apiPath,
3616
- method: upperMethod,
3617
- module: extractModuleFromPath2(apiPath)
3618
- });
3619
- });
3620
- }
3621
- if (layer.name === "router" && layer.handle?.stack) {
3622
- let prefix = basePath;
3623
- if (layer.regexp) {
3624
- const pattern = new RegExp("^\\^\\\\?(.*?)(?:\\\\/\\?|$)");
3625
- const match = layer.regexp.source.match(pattern);
3626
- if (match) {
3627
- prefix = basePath + match[1].replace(/\\\//g, "/");
3628
- }
3629
- }
3630
- layer.handle.stack.forEach((subLayer) => processLayer(subLayer, prefix));
3631
- }
3632
- }, "processLayer");
3633
- router.stack.forEach((layer) => processLayer(layer));
3634
- return routes;
3635
- }
3636
- __name(extractRoutes, "extractRoutes");
3637
- function groupRoutesByModule2(routes) {
3638
- const groupMap = /* @__PURE__ */ new Map();
3639
- routes.forEach((route) => {
3640
- const existing = groupMap.get(route.module) || [];
3641
- existing.push(route);
3642
- groupMap.set(route.module, existing);
3643
- });
3644
- const groups = [];
3645
- groupMap.forEach((apis, moduleName) => {
3646
- groups.push({
3647
- id: moduleName,
3648
- name: capitalize2(moduleName),
3649
- apis: apis.sort((a, b) => a.path.localeCompare(b.path))
3650
- });
3651
- });
3652
- return groups.sort((a, b) => a.name.localeCompare(b.name));
3653
- }
3654
- __name(groupRoutesByModule2, "groupRoutesByModule");
3655
- function createApiRoutesRouter() {
3656
- console.log("[api-routes] createApiRoutesRouter called");
3657
- const router = express4.Router();
3658
- console.log("[api-routes] router created, adding /api-list route");
3659
- router.get("/api-list", (req, res) => {
3660
- console.log("[api-routes] /api-list handler called");
3661
- res.header("Access-Control-Allow-Origin", "*");
3662
- res.header("Access-Control-Allow-Methods", "GET, OPTIONS");
3663
- res.header("Access-Control-Allow-Headers", "Content-Type, Accept");
3664
- try {
3665
- const routes = extractRoutes(req.app);
3666
- const groups = groupRoutesByModule2(routes);
3667
- res.json({
3668
- groups,
3669
- total: routes.length
3670
- });
3671
- } catch (error) {
3672
- console.error("[api-routes] Failed to extract routes:", error);
3673
- res.status(500).json({
3674
- error: "Failed to extract routes",
3675
- message: error instanceof Error ? error.message : "Unknown error"
3676
- });
3677
- }
3678
- });
3679
- return router;
3680
3464
  }
3681
- __name(createApiRoutesRouter, "createApiRoutesRouter");
3682
-
3683
- // src/middlewares/api-routes/index.ts
3684
- var API_ROUTES_ROUTES = [
3685
- {
3686
- method: "GET",
3687
- path: "/api-list",
3688
- description: "Get all API routes grouped by module"
3465
+ __name(sendJson, "sendJson");
3466
+ function sendError(res, message, error, statusCode = 500) {
3467
+ const errorData = {
3468
+ message,
3469
+ ...error ? {
3470
+ error: serializeError3(error)
3471
+ } : {}
3472
+ };
3473
+ sendJson(res, errorData, statusCode);
3474
+ }
3475
+ __name(sendError, "sendError");
3476
+ function sendSuccess(res, data) {
3477
+ sendJson(res, {
3478
+ success: true,
3479
+ ...data
3480
+ }, 200);
3481
+ }
3482
+ __name(sendSuccess, "sendSuccess");
3483
+ function getQuery(req) {
3484
+ if (req.query) {
3485
+ return req.query;
3486
+ }
3487
+ const url = new URL(req.url || "", `http://${req.headers.host}`);
3488
+ return Object.fromEntries(url.searchParams.entries());
3489
+ }
3490
+ __name(getQuery, "getQuery");
3491
+ function getQueryParam(req, key) {
3492
+ const query = getQuery(req);
3493
+ return query[key];
3494
+ }
3495
+ __name(getQueryParam, "getQueryParam");
3496
+ function serializeError3(error) {
3497
+ if (error instanceof Error) {
3498
+ return {
3499
+ name: error.name,
3500
+ message: error.message,
3501
+ stack: error.stack
3502
+ };
3689
3503
  }
3690
- ];
3691
- function createApiRoutesMiddleware() {
3692
3504
  return {
3693
- name: "api-routes",
3694
- mountPath: "/dev/api",
3695
- routes: API_ROUTES_ROUTES,
3696
- enabled: /* @__PURE__ */ __name((context) => context.isDev, "enabled"),
3697
- createRouter: /* @__PURE__ */ __name((_context) => {
3698
- return createApiRoutesRouter();
3699
- }, "createRouter")
3505
+ message: String(error)
3700
3506
  };
3701
3507
  }
3702
- __name(createApiRoutesMiddleware, "createApiRoutesMiddleware");
3508
+ __name(serializeError3, "serializeError");
3703
3509
 
3704
3510
  // src/middlewares/index.ts
3511
+ function enhanceForCompat(req, res) {
3512
+ if (!res.status) {
3513
+ res.status = function(code) {
3514
+ res.statusCode = code;
3515
+ return res;
3516
+ };
3517
+ }
3518
+ if (!res.json) {
3519
+ res.json = function(data) {
3520
+ res.setHeader("Content-Type", "application/json");
3521
+ res.end(JSON.stringify(data));
3522
+ return res;
3523
+ };
3524
+ }
3525
+ if (!res.send) {
3526
+ res.send = function(data) {
3527
+ if (typeof data === "object" && data !== null) {
3528
+ res.setHeader("Content-Type", "application/json");
3529
+ res.end(JSON.stringify(data));
3530
+ } else {
3531
+ res.end(String(data));
3532
+ }
3533
+ return res;
3534
+ };
3535
+ }
3536
+ if (!req.query) {
3537
+ const url = new URL(req.url || "", `http://${req.headers.host || "localhost"}`);
3538
+ req.query = Object.fromEntries(url.searchParams.entries());
3539
+ }
3540
+ }
3541
+ __name(enhanceForCompat, "enhanceForCompat");
3542
+ function isConnectServer(server) {
3543
+ return typeof server === "function" && !("set" in server) && !("engine" in server);
3544
+ }
3545
+ __name(isConnectServer, "isConnectServer");
3705
3546
  function isRouteMiddleware(middleware) {
3706
3547
  return "createRouter" in middleware && middleware.createRouter !== void 0;
3707
3548
  }
@@ -3754,6 +3595,13 @@ async function registerMiddlewares(server, middlewares, options) {
3754
3595
  rootDir: process.cwd(),
3755
3596
  ...options
3756
3597
  };
3598
+ if (isConnectServer(server)) {
3599
+ server.use((req, res, next) => {
3600
+ enhanceForCompat(req, res);
3601
+ next();
3602
+ });
3603
+ console.log("[Middleware] Registered Express compatibility layer for Connect/Vite");
3604
+ }
3757
3605
  const allMiddlewares = [
3758
3606
  ...middlewares
3759
3607
  ];
@@ -3781,14 +3629,18 @@ async function registerMiddlewares(server, middlewares, options) {
3781
3629
  }
3782
3630
  __name(registerMiddlewares, "registerMiddlewares");
3783
3631
  export {
3784
- createApiRoutesMiddleware,
3785
3632
  createCollectLogsMiddleware,
3786
3633
  createDevLogsMiddleware,
3787
3634
  createOpenapiMiddleware,
3635
+ getQuery,
3636
+ getQueryParam,
3788
3637
  handleDevProxyError,
3789
3638
  normalizeBasePath,
3790
3639
  parseAndGenerateNestResourceTemplate,
3791
3640
  postprocessDrizzleSchema,
3792
- registerMiddlewares
3641
+ registerMiddlewares,
3642
+ sendError,
3643
+ sendJson,
3644
+ sendSuccess
3793
3645
  };
3794
3646
  //# sourceMappingURL=index.js.map