@lark-apaas/devtool-kits 0.1.0-alpha.8 → 1.0.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/dist/index.cjs CHANGED
@@ -1370,8 +1370,8 @@ var require_node = __commonJS({
1370
1370
  }
1371
1371
  break;
1372
1372
  case "FILE":
1373
- var fs9 = require("fs");
1374
- stream2 = new fs9.SyncWriteStream(fd2, {
1373
+ var fs10 = require("fs");
1374
+ stream2 = new fs10.SyncWriteStream(fd2, {
1375
1375
  autoClose: false
1376
1376
  });
1377
1377
  stream2._type = "fs";
@@ -17559,11 +17559,11 @@ var require_mime_types = __commonJS({
17559
17559
  return exts[0];
17560
17560
  }
17561
17561
  __name(extension, "extension");
17562
- function lookup(path5) {
17563
- if (!path5 || typeof path5 !== "string") {
17562
+ function lookup(path6) {
17563
+ if (!path6 || typeof path6 !== "string") {
17564
17564
  return false;
17565
17565
  }
17566
- var extension2 = extname("x." + path5).toLowerCase().substr(1);
17566
+ var extension2 = extname("x." + path6).toLowerCase().substr(1);
17567
17567
  if (!extension2) {
17568
17568
  return false;
17569
17569
  }
@@ -21250,8 +21250,8 @@ var require_node2 = __commonJS({
21250
21250
  }
21251
21251
  break;
21252
21252
  case "FILE":
21253
- var fs9 = require("fs");
21254
- stream2 = new fs9.SyncWriteStream(fd2, {
21253
+ var fs10 = require("fs");
21254
+ stream2 = new fs10.SyncWriteStream(fd2, {
21255
21255
  autoClose: false
21256
21256
  });
21257
21257
  stream2._type = "fs";
@@ -22020,8 +22020,8 @@ var require_node3 = __commonJS({
22020
22020
  }
22021
22021
  break;
22022
22022
  case "FILE":
22023
- var fs9 = require("fs");
22024
- stream2 = new fs9.SyncWriteStream(fd2, {
22023
+ var fs10 = require("fs");
22024
+ stream2 = new fs10.SyncWriteStream(fd2, {
22025
22025
  autoClose: false
22026
22026
  });
22027
22027
  stream2._type = "fs";
@@ -22118,7 +22118,7 @@ var require_path_to_regexp = __commonJS({
22118
22118
  "use strict";
22119
22119
  module2.exports = pathToRegexp;
22120
22120
  var MATCHING_GROUP_REGEXP = /\\.|\((?:\?<(.*?)>)?(?!\?)/g;
22121
- function pathToRegexp(path5, keys, options) {
22121
+ function pathToRegexp(path6, keys, options) {
22122
22122
  options = options || {};
22123
22123
  keys = keys || [];
22124
22124
  var strict = options.strict;
@@ -22132,8 +22132,8 @@ var require_path_to_regexp = __commonJS({
22132
22132
  var pos = 0;
22133
22133
  var backtrack = "";
22134
22134
  var m;
22135
- if (path5 instanceof RegExp) {
22136
- while (m = MATCHING_GROUP_REGEXP.exec(path5.source)) {
22135
+ if (path6 instanceof RegExp) {
22136
+ while (m = MATCHING_GROUP_REGEXP.exec(path6.source)) {
22137
22137
  if (m[0][0] === "\\") continue;
22138
22138
  keys.push({
22139
22139
  name: m[1] || name++,
@@ -22141,18 +22141,18 @@ var require_path_to_regexp = __commonJS({
22141
22141
  offset: m.index
22142
22142
  });
22143
22143
  }
22144
- return path5;
22144
+ return path6;
22145
22145
  }
22146
- if (Array.isArray(path5)) {
22147
- path5 = path5.map(function(value) {
22146
+ if (Array.isArray(path6)) {
22147
+ path6 = path6.map(function(value) {
22148
22148
  return pathToRegexp(value, keys, options).source;
22149
22149
  });
22150
- return new RegExp(path5.join("|"), flags);
22150
+ return new RegExp(path6.join("|"), flags);
22151
22151
  }
22152
- if (typeof path5 !== "string") {
22152
+ if (typeof path6 !== "string") {
22153
22153
  throw new TypeError("path must be a string, array of strings, or regular expression");
22154
22154
  }
22155
- path5 = path5.replace(/\\.|(\/)?(\.)?:(\w+)(\(.*?\))?(\*)?(\?)?|[.*]|\/\(/g, function(match, slash, format, key, capture, star, optional, offset) {
22155
+ path6 = path6.replace(/\\.|(\/)?(\.)?:(\w+)(\(.*?\))?(\*)?(\?)?|[.*]|\/\(/g, function(match, slash, format, key, capture, star, optional, offset) {
22156
22156
  if (match[0] === "\\") {
22157
22157
  backtrack += match;
22158
22158
  pos += 2;
@@ -22167,7 +22167,7 @@ var require_path_to_regexp = __commonJS({
22167
22167
  if (slash || format) {
22168
22168
  backtrack = "";
22169
22169
  } else {
22170
- backtrack += path5.slice(pos, offset);
22170
+ backtrack += path6.slice(pos, offset);
22171
22171
  }
22172
22172
  pos = offset + match.length;
22173
22173
  if (match === "*") {
@@ -22194,7 +22194,7 @@ var require_path_to_regexp = __commonJS({
22194
22194
  extraOffset += result.length - match.length;
22195
22195
  return result;
22196
22196
  });
22197
- while (m = MATCHING_GROUP_REGEXP.exec(path5)) {
22197
+ while (m = MATCHING_GROUP_REGEXP.exec(path6)) {
22198
22198
  if (m[0][0] === "\\") continue;
22199
22199
  if (keysOffset + i === keys.length || keys[keysOffset + i].offset > m.index) {
22200
22200
  keys.splice(keysOffset + i, 0, {
@@ -22205,13 +22205,13 @@ var require_path_to_regexp = __commonJS({
22205
22205
  }
22206
22206
  i++;
22207
22207
  }
22208
- path5 += strict ? "" : path5[path5.length - 1] === "/" ? "?" : "/?";
22208
+ path6 += strict ? "" : path6[path6.length - 1] === "/" ? "?" : "/?";
22209
22209
  if (end) {
22210
- path5 += "$";
22211
- } else if (path5[path5.length - 1] !== "/") {
22212
- path5 += lookahead ? "(?=/|$)" : "(?:/|$)";
22210
+ path6 += "$";
22211
+ } else if (path6[path6.length - 1] !== "/") {
22212
+ path6 += lookahead ? "(?=/|$)" : "(?:/|$)";
22213
22213
  }
22214
- return new RegExp("^" + path5, flags);
22214
+ return new RegExp("^" + path6, flags);
22215
22215
  }
22216
22216
  __name(pathToRegexp, "pathToRegexp");
22217
22217
  }
@@ -22225,19 +22225,19 @@ var require_layer = __commonJS({
22225
22225
  var debug = require_src3()("express:router:layer");
22226
22226
  var hasOwnProperty = Object.prototype.hasOwnProperty;
22227
22227
  module2.exports = Layer;
22228
- function Layer(path5, options, fn) {
22228
+ function Layer(path6, options, fn) {
22229
22229
  if (!(this instanceof Layer)) {
22230
- return new Layer(path5, options, fn);
22230
+ return new Layer(path6, options, fn);
22231
22231
  }
22232
- debug("new %o", path5);
22232
+ debug("new %o", path6);
22233
22233
  var opts = options || {};
22234
22234
  this.handle = fn;
22235
22235
  this.name = fn.name || "<anonymous>";
22236
22236
  this.params = void 0;
22237
22237
  this.path = void 0;
22238
- this.regexp = pathRegexp(path5, this.keys = [], opts);
22239
- this.regexp.fast_star = path5 === "*";
22240
- this.regexp.fast_slash = path5 === "/" && opts.end === false;
22238
+ this.regexp = pathRegexp(path6, this.keys = [], opts);
22239
+ this.regexp.fast_star = path6 === "*";
22240
+ this.regexp.fast_slash = path6 === "/" && opts.end === false;
22241
22241
  }
22242
22242
  __name(Layer, "Layer");
22243
22243
  Layer.prototype.handle_error = /* @__PURE__ */ __name(function handle_error(error, req, res, next) {
@@ -22262,9 +22262,9 @@ var require_layer = __commonJS({
22262
22262
  next(err);
22263
22263
  }
22264
22264
  }, "handle");
22265
- Layer.prototype.match = /* @__PURE__ */ __name(function match(path5) {
22265
+ Layer.prototype.match = /* @__PURE__ */ __name(function match(path6) {
22266
22266
  var match2;
22267
- if (path5 != null) {
22267
+ if (path6 != null) {
22268
22268
  if (this.regexp.fast_slash) {
22269
22269
  this.params = {};
22270
22270
  this.path = "";
@@ -22272,12 +22272,12 @@ var require_layer = __commonJS({
22272
22272
  }
22273
22273
  if (this.regexp.fast_star) {
22274
22274
  this.params = {
22275
- "0": decode_param(path5)
22275
+ "0": decode_param(path6)
22276
22276
  };
22277
- this.path = path5;
22277
+ this.path = path6;
22278
22278
  return true;
22279
22279
  }
22280
- match2 = this.regexp.exec(path5);
22280
+ match2 = this.regexp.exec(path6);
22281
22281
  }
22282
22282
  if (!match2) {
22283
22283
  this.params = void 0;
@@ -22373,10 +22373,10 @@ var require_route = __commonJS({
22373
22373
  var slice = Array.prototype.slice;
22374
22374
  var toString = Object.prototype.toString;
22375
22375
  module2.exports = Route;
22376
- function Route(path5) {
22377
- this.path = path5;
22376
+ function Route(path6) {
22377
+ this.path = path6;
22378
22378
  this.stack = [];
22379
- debug("new %o", path5);
22379
+ debug("new %o", path6);
22380
22380
  this.methods = {};
22381
22381
  }
22382
22382
  __name(Route, "Route");
@@ -22592,8 +22592,8 @@ var require_router = __commonJS({
22592
22592
  if (++sync > 100) {
22593
22593
  return setImmediate(next, err);
22594
22594
  }
22595
- var path5 = getPathname(req);
22596
- if (path5 == null) {
22595
+ var path6 = getPathname(req);
22596
+ if (path6 == null) {
22597
22597
  return done(layerError);
22598
22598
  }
22599
22599
  var layer;
@@ -22601,7 +22601,7 @@ var require_router = __commonJS({
22601
22601
  var route;
22602
22602
  while (match !== true && idx < stack.length) {
22603
22603
  layer = stack[idx++];
22604
- match = matchLayer(layer, path5);
22604
+ match = matchLayer(layer, path6);
22605
22605
  route = layer.route;
22606
22606
  if (typeof match !== "boolean") {
22607
22607
  layerError = layerError || match;
@@ -22639,19 +22639,19 @@ var require_router = __commonJS({
22639
22639
  } else if (route) {
22640
22640
  layer.handle_request(req, res, next);
22641
22641
  } else {
22642
- trim_prefix(layer, layerError, layerPath, path5);
22642
+ trim_prefix(layer, layerError, layerPath, path6);
22643
22643
  }
22644
22644
  sync = 0;
22645
22645
  });
22646
22646
  }
22647
22647
  __name(next, "next");
22648
- function trim_prefix(layer, layerError, layerPath, path5) {
22648
+ function trim_prefix(layer, layerError, layerPath, path6) {
22649
22649
  if (layerPath.length !== 0) {
22650
- if (layerPath !== path5.slice(0, layerPath.length)) {
22650
+ if (layerPath !== path6.slice(0, layerPath.length)) {
22651
22651
  next(layerError);
22652
22652
  return;
22653
22653
  }
22654
- var c = path5[layerPath.length];
22654
+ var c = path6[layerPath.length];
22655
22655
  if (c && c !== "/" && c !== ".") return next(layerError);
22656
22656
  debug("trim prefix (%s) from url %s", layerPath, req.url);
22657
22657
  removed = layerPath;
@@ -22732,7 +22732,7 @@ var require_router = __commonJS({
22732
22732
  }, "process_params");
22733
22733
  proto.use = /* @__PURE__ */ __name(function use(fn) {
22734
22734
  var offset = 0;
22735
- var path5 = "/";
22735
+ var path6 = "/";
22736
22736
  if (typeof fn !== "function") {
22737
22737
  var arg = fn;
22738
22738
  while (Array.isArray(arg) && arg.length !== 0) {
@@ -22740,7 +22740,7 @@ var require_router = __commonJS({
22740
22740
  }
22741
22741
  if (typeof arg !== "function") {
22742
22742
  offset = 1;
22743
- path5 = fn;
22743
+ path6 = fn;
22744
22744
  }
22745
22745
  }
22746
22746
  var callbacks = flatten(slice.call(arguments, offset));
@@ -22752,8 +22752,8 @@ var require_router = __commonJS({
22752
22752
  if (typeof fn !== "function") {
22753
22753
  throw new TypeError("Router.use() requires a middleware function but got a " + gettype(fn));
22754
22754
  }
22755
- debug("use %o %s", path5, fn.name || "<anonymous>");
22756
- var layer = new Layer(path5, {
22755
+ debug("use %o %s", path6, fn.name || "<anonymous>");
22756
+ var layer = new Layer(path6, {
22757
22757
  sensitive: this.caseSensitive,
22758
22758
  strict: false,
22759
22759
  end: false
@@ -22763,9 +22763,9 @@ var require_router = __commonJS({
22763
22763
  }
22764
22764
  return this;
22765
22765
  }, "use");
22766
- proto.route = /* @__PURE__ */ __name(function route(path5) {
22767
- var route2 = new Route(path5);
22768
- var layer = new Layer(path5, {
22766
+ proto.route = /* @__PURE__ */ __name(function route(path6) {
22767
+ var route2 = new Route(path6);
22768
+ var layer = new Layer(path6, {
22769
22769
  sensitive: this.caseSensitive,
22770
22770
  strict: this.strict,
22771
22771
  end: true
@@ -22775,8 +22775,8 @@ var require_router = __commonJS({
22775
22775
  return route2;
22776
22776
  }, "route");
22777
22777
  methods.concat("all").forEach(function(method) {
22778
- proto[method] = function(path5) {
22779
- var route = this.route(path5);
22778
+ proto[method] = function(path6) {
22779
+ var route = this.route(path6);
22780
22780
  route[method].apply(route, slice.call(arguments, 1));
22781
22781
  return this;
22782
22782
  };
@@ -22816,9 +22816,9 @@ var require_router = __commonJS({
22816
22816
  return toString.call(obj).replace(objectRegExp, "$1");
22817
22817
  }
22818
22818
  __name(gettype, "gettype");
22819
- function matchLayer(layer, path5) {
22819
+ function matchLayer(layer, path6) {
22820
22820
  try {
22821
- return layer.match(path5);
22821
+ return layer.match(path6);
22822
22822
  } catch (err) {
22823
22823
  return err;
22824
22824
  }
@@ -22941,13 +22941,13 @@ var require_view = __commonJS({
22941
22941
  "../../../node_modules/express/lib/view.js"(exports2, module2) {
22942
22942
  "use strict";
22943
22943
  var debug = require_src3()("express:view");
22944
- var path5 = require("path");
22945
- var fs9 = require("fs");
22946
- var dirname = path5.dirname;
22947
- var basename = path5.basename;
22948
- var extname = path5.extname;
22949
- var join5 = path5.join;
22950
- var resolve = path5.resolve;
22944
+ var path6 = require("path");
22945
+ var fs10 = require("fs");
22946
+ var dirname = path6.dirname;
22947
+ var basename = path6.basename;
22948
+ var extname = path6.extname;
22949
+ var join5 = path6.join;
22950
+ var resolve = path6.resolve;
22951
22951
  module2.exports = View;
22952
22952
  function View(name, options) {
22953
22953
  var opts = options || {};
@@ -22977,17 +22977,17 @@ var require_view = __commonJS({
22977
22977
  }
22978
22978
  __name(View, "View");
22979
22979
  View.prototype.lookup = /* @__PURE__ */ __name(function lookup(name) {
22980
- var path6;
22980
+ var path7;
22981
22981
  var roots = [].concat(this.root);
22982
22982
  debug('lookup "%s"', name);
22983
- for (var i = 0; i < roots.length && !path6; i++) {
22983
+ for (var i = 0; i < roots.length && !path7; i++) {
22984
22984
  var root = roots[i];
22985
22985
  var loc = resolve(root, name);
22986
22986
  var dir = dirname(loc);
22987
22987
  var file = basename(loc);
22988
- path6 = this.resolve(dir, file);
22988
+ path7 = this.resolve(dir, file);
22989
22989
  }
22990
- return path6;
22990
+ return path7;
22991
22991
  }, "lookup");
22992
22992
  View.prototype.render = /* @__PURE__ */ __name(function render(options, callback) {
22993
22993
  debug('render "%s"', this.path);
@@ -22995,21 +22995,21 @@ var require_view = __commonJS({
22995
22995
  }, "render");
22996
22996
  View.prototype.resolve = /* @__PURE__ */ __name(function resolve2(dir, file) {
22997
22997
  var ext = this.ext;
22998
- var path6 = join5(dir, file);
22999
- var stat = tryStat(path6);
22998
+ var path7 = join5(dir, file);
22999
+ var stat = tryStat(path7);
23000
23000
  if (stat && stat.isFile()) {
23001
- return path6;
23001
+ return path7;
23002
23002
  }
23003
- path6 = join5(dir, basename(file, ext), "index" + ext);
23004
- stat = tryStat(path6);
23003
+ path7 = join5(dir, basename(file, ext), "index" + ext);
23004
+ stat = tryStat(path7);
23005
23005
  if (stat && stat.isFile()) {
23006
- return path6;
23006
+ return path7;
23007
23007
  }
23008
23008
  }, "resolve");
23009
- function tryStat(path6) {
23010
- debug('stat "%s"', path6);
23009
+ function tryStat(path7) {
23010
+ debug('stat "%s"', path7);
23011
23011
  try {
23012
- return fs9.statSync(path6);
23012
+ return fs10.statSync(path7);
23013
23013
  } catch (e) {
23014
23014
  return void 0;
23015
23015
  }
@@ -23658,8 +23658,8 @@ var require_node4 = __commonJS({
23658
23658
  }
23659
23659
  break;
23660
23660
  case "FILE":
23661
- var fs9 = require("fs");
23662
- stream2 = new fs9.SyncWriteStream(fd2, {
23661
+ var fs10 = require("fs");
23662
+ stream2 = new fs10.SyncWriteStream(fd2, {
23663
23663
  autoClose: false
23664
23664
  });
23665
23665
  stream2._type = "fs";
@@ -23859,8 +23859,8 @@ var require_types = __commonJS({
23859
23859
  var require_mime = __commonJS({
23860
23860
  "../../../node_modules/mime/mime.js"(exports2, module2) {
23861
23861
  "use strict";
23862
- var path5 = require("path");
23863
- var fs9 = require("fs");
23862
+ var path6 = require("path");
23863
+ var fs10 = require("fs");
23864
23864
  function Mime() {
23865
23865
  this.types = /* @__PURE__ */ Object.create(null);
23866
23866
  this.extensions = /* @__PURE__ */ Object.create(null);
@@ -23882,7 +23882,7 @@ var require_mime = __commonJS({
23882
23882
  };
23883
23883
  Mime.prototype.load = function(file) {
23884
23884
  this._loading = file;
23885
- var map = {}, content = fs9.readFileSync(file, "ascii"), lines = content.split(/[\r\n]+/);
23885
+ var map = {}, content = fs10.readFileSync(file, "ascii"), lines = content.split(/[\r\n]+/);
23886
23886
  lines.forEach(function(line) {
23887
23887
  var fields = line.replace(/\s*#.*|^\s*|\s*$/g, "").split(/\s+/);
23888
23888
  map[fields.shift()] = fields;
@@ -23890,8 +23890,8 @@ var require_mime = __commonJS({
23890
23890
  this.define(map);
23891
23891
  this._loading = null;
23892
23892
  };
23893
- Mime.prototype.lookup = function(path6, fallback) {
23894
- var ext = path6.replace(/^.*[\.\/\\]/, "").toLowerCase();
23893
+ Mime.prototype.lookup = function(path7, fallback) {
23894
+ var ext = path7.replace(/^.*[\.\/\\]/, "").toLowerCase();
23895
23895
  return this.types[ext] || fallback || this.default_type;
23896
23896
  };
23897
23897
  Mime.prototype.extension = function(mimeType) {
@@ -24127,34 +24127,34 @@ var require_send = __commonJS({
24127
24127
  var escapeHtml = require_escape_html();
24128
24128
  var etag = require_etag();
24129
24129
  var fresh = require_fresh();
24130
- var fs9 = require("fs");
24130
+ var fs10 = require("fs");
24131
24131
  var mime = require_mime();
24132
24132
  var ms = require_ms5();
24133
24133
  var onFinished = require_on_finished();
24134
24134
  var parseRange = require_range_parser();
24135
- var path5 = require("path");
24135
+ var path6 = require("path");
24136
24136
  var statuses = require_statuses();
24137
24137
  var Stream = require("stream");
24138
24138
  var util = require("util");
24139
- var extname = path5.extname;
24140
- var join5 = path5.join;
24141
- var normalize = path5.normalize;
24142
- var resolve = path5.resolve;
24143
- var sep = path5.sep;
24139
+ var extname = path6.extname;
24140
+ var join5 = path6.join;
24141
+ var normalize = path6.normalize;
24142
+ var resolve = path6.resolve;
24143
+ var sep = path6.sep;
24144
24144
  var BYTES_RANGE_REGEXP = /^ *bytes=/;
24145
24145
  var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1e3;
24146
24146
  var UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
24147
24147
  module2.exports = send;
24148
24148
  module2.exports.mime = mime;
24149
- function send(req, path6, options) {
24150
- return new SendStream(req, path6, options);
24149
+ function send(req, path7, options) {
24150
+ return new SendStream(req, path7, options);
24151
24151
  }
24152
24152
  __name(send, "send");
24153
- function SendStream(req, path6, options) {
24153
+ function SendStream(req, path7, options) {
24154
24154
  Stream.call(this);
24155
24155
  var opts = options || {};
24156
24156
  this.options = opts;
24157
- this.path = path6;
24157
+ this.path = path7;
24158
24158
  this.req = req;
24159
24159
  this._acceptRanges = opts.acceptRanges !== void 0 ? Boolean(opts.acceptRanges) : true;
24160
24160
  this._cacheControl = opts.cacheControl !== void 0 ? Boolean(opts.cacheControl) : true;
@@ -24203,8 +24203,8 @@ var require_send = __commonJS({
24203
24203
  this._index = index2;
24204
24204
  return this;
24205
24205
  }, "index"), "send.index: pass index as option");
24206
- SendStream.prototype.root = /* @__PURE__ */ __name(function root(path6) {
24207
- this._root = resolve(String(path6));
24206
+ SendStream.prototype.root = /* @__PURE__ */ __name(function root(path7) {
24207
+ this._root = resolve(String(path7));
24208
24208
  debug("root %s", this._root);
24209
24209
  return this;
24210
24210
  }, "root");
@@ -24311,10 +24311,10 @@ var require_send = __commonJS({
24311
24311
  var lastModified = this.res.getHeader("Last-Modified");
24312
24312
  return parseHttpDate(lastModified) <= parseHttpDate(ifRange);
24313
24313
  }, "isRangeFresh");
24314
- SendStream.prototype.redirect = /* @__PURE__ */ __name(function redirect(path6) {
24314
+ SendStream.prototype.redirect = /* @__PURE__ */ __name(function redirect(path7) {
24315
24315
  var res = this.res;
24316
24316
  if (hasListeners(this, "directory")) {
24317
- this.emit("directory", res, path6);
24317
+ this.emit("directory", res, path7);
24318
24318
  return;
24319
24319
  }
24320
24320
  if (this.hasTrailingSlash()) {
@@ -24334,42 +24334,42 @@ var require_send = __commonJS({
24334
24334
  SendStream.prototype.pipe = /* @__PURE__ */ __name(function pipe(res) {
24335
24335
  var root = this._root;
24336
24336
  this.res = res;
24337
- var path6 = decode(this.path);
24338
- if (path6 === -1) {
24337
+ var path7 = decode(this.path);
24338
+ if (path7 === -1) {
24339
24339
  this.error(400);
24340
24340
  return res;
24341
24341
  }
24342
- if (~path6.indexOf("\0")) {
24342
+ if (~path7.indexOf("\0")) {
24343
24343
  this.error(400);
24344
24344
  return res;
24345
24345
  }
24346
24346
  var parts;
24347
24347
  if (root !== null) {
24348
- if (path6) {
24349
- path6 = normalize("." + sep + path6);
24348
+ if (path7) {
24349
+ path7 = normalize("." + sep + path7);
24350
24350
  }
24351
- if (UP_PATH_REGEXP.test(path6)) {
24352
- debug('malicious path "%s"', path6);
24351
+ if (UP_PATH_REGEXP.test(path7)) {
24352
+ debug('malicious path "%s"', path7);
24353
24353
  this.error(403);
24354
24354
  return res;
24355
24355
  }
24356
- parts = path6.split(sep);
24357
- path6 = normalize(join5(root, path6));
24356
+ parts = path7.split(sep);
24357
+ path7 = normalize(join5(root, path7));
24358
24358
  } else {
24359
- if (UP_PATH_REGEXP.test(path6)) {
24360
- debug('malicious path "%s"', path6);
24359
+ if (UP_PATH_REGEXP.test(path7)) {
24360
+ debug('malicious path "%s"', path7);
24361
24361
  this.error(403);
24362
24362
  return res;
24363
24363
  }
24364
- parts = normalize(path6).split(sep);
24365
- path6 = resolve(path6);
24364
+ parts = normalize(path7).split(sep);
24365
+ path7 = resolve(path7);
24366
24366
  }
24367
24367
  if (containsDotFile(parts)) {
24368
24368
  var access = this._dotfiles;
24369
24369
  if (access === void 0) {
24370
24370
  access = parts[parts.length - 1][0] === "." ? this._hidden ? "allow" : "ignore" : "allow";
24371
24371
  }
24372
- debug('%s dotfile "%s"', access, path6);
24372
+ debug('%s dotfile "%s"', access, path7);
24373
24373
  switch (access) {
24374
24374
  case "allow":
24375
24375
  break;
@@ -24383,13 +24383,13 @@ var require_send = __commonJS({
24383
24383
  }
24384
24384
  }
24385
24385
  if (this._index.length && this.hasTrailingSlash()) {
24386
- this.sendIndex(path6);
24386
+ this.sendIndex(path7);
24387
24387
  return res;
24388
24388
  }
24389
- this.sendFile(path6);
24389
+ this.sendFile(path7);
24390
24390
  return res;
24391
24391
  }, "pipe");
24392
- SendStream.prototype.send = /* @__PURE__ */ __name(function send2(path6, stat) {
24392
+ SendStream.prototype.send = /* @__PURE__ */ __name(function send2(path7, stat) {
24393
24393
  var len = stat.size;
24394
24394
  var options = this.options;
24395
24395
  var opts = {};
@@ -24401,9 +24401,9 @@ var require_send = __commonJS({
24401
24401
  this.headersAlreadySent();
24402
24402
  return;
24403
24403
  }
24404
- debug('pipe "%s"', path6);
24405
- this.setHeader(path6, stat);
24406
- this.type(path6);
24404
+ debug('pipe "%s"', path7);
24405
+ this.setHeader(path7, stat);
24406
+ this.type(path7);
24407
24407
  if (this.isConditionalGET()) {
24408
24408
  if (this.isPreconditionFailure()) {
24409
24409
  this.error(412);
@@ -24454,28 +24454,28 @@ var require_send = __commonJS({
24454
24454
  res.end();
24455
24455
  return;
24456
24456
  }
24457
- this.stream(path6, opts);
24457
+ this.stream(path7, opts);
24458
24458
  }, "send");
24459
- SendStream.prototype.sendFile = /* @__PURE__ */ __name(function sendFile(path6) {
24459
+ SendStream.prototype.sendFile = /* @__PURE__ */ __name(function sendFile(path7) {
24460
24460
  var i = 0;
24461
24461
  var self = this;
24462
- debug('stat "%s"', path6);
24463
- fs9.stat(path6, /* @__PURE__ */ __name(function onstat(err, stat) {
24464
- if (err && err.code === "ENOENT" && !extname(path6) && path6[path6.length - 1] !== sep) {
24462
+ debug('stat "%s"', path7);
24463
+ fs10.stat(path7, /* @__PURE__ */ __name(function onstat(err, stat) {
24464
+ if (err && err.code === "ENOENT" && !extname(path7) && path7[path7.length - 1] !== sep) {
24465
24465
  return next(err);
24466
24466
  }
24467
24467
  if (err) return self.onStatError(err);
24468
- if (stat.isDirectory()) return self.redirect(path6);
24469
- self.emit("file", path6, stat);
24470
- self.send(path6, stat);
24468
+ if (stat.isDirectory()) return self.redirect(path7);
24469
+ self.emit("file", path7, stat);
24470
+ self.send(path7, stat);
24471
24471
  }, "onstat"));
24472
24472
  function next(err) {
24473
24473
  if (self._extensions.length <= i) {
24474
24474
  return err ? self.onStatError(err) : self.error(404);
24475
24475
  }
24476
- var p = path6 + "." + self._extensions[i++];
24476
+ var p = path7 + "." + self._extensions[i++];
24477
24477
  debug('stat "%s"', p);
24478
- fs9.stat(p, function(err2, stat) {
24478
+ fs10.stat(p, function(err2, stat) {
24479
24479
  if (err2) return next(err2);
24480
24480
  if (stat.isDirectory()) return next();
24481
24481
  self.emit("file", p, stat);
@@ -24484,7 +24484,7 @@ var require_send = __commonJS({
24484
24484
  }
24485
24485
  __name(next, "next");
24486
24486
  }, "sendFile");
24487
- SendStream.prototype.sendIndex = /* @__PURE__ */ __name(function sendIndex(path6) {
24487
+ SendStream.prototype.sendIndex = /* @__PURE__ */ __name(function sendIndex(path7) {
24488
24488
  var i = -1;
24489
24489
  var self = this;
24490
24490
  function next(err) {
@@ -24492,9 +24492,9 @@ var require_send = __commonJS({
24492
24492
  if (err) return self.onStatError(err);
24493
24493
  return self.error(404);
24494
24494
  }
24495
- var p = join5(path6, self._index[i]);
24495
+ var p = join5(path7, self._index[i]);
24496
24496
  debug('stat "%s"', p);
24497
- fs9.stat(p, function(err2, stat) {
24497
+ fs10.stat(p, function(err2, stat) {
24498
24498
  if (err2) return next(err2);
24499
24499
  if (stat.isDirectory()) return next();
24500
24500
  self.emit("file", p, stat);
@@ -24504,10 +24504,10 @@ var require_send = __commonJS({
24504
24504
  __name(next, "next");
24505
24505
  next();
24506
24506
  }, "sendIndex");
24507
- SendStream.prototype.stream = /* @__PURE__ */ __name(function stream(path6, options) {
24507
+ SendStream.prototype.stream = /* @__PURE__ */ __name(function stream(path7, options) {
24508
24508
  var self = this;
24509
24509
  var res = this.res;
24510
- var stream2 = fs9.createReadStream(path6, options);
24510
+ var stream2 = fs10.createReadStream(path7, options);
24511
24511
  this.emit("stream", stream2);
24512
24512
  stream2.pipe(res);
24513
24513
  function cleanup() {
@@ -24523,10 +24523,10 @@ var require_send = __commonJS({
24523
24523
  self.emit("end");
24524
24524
  }, "onend"));
24525
24525
  }, "stream");
24526
- SendStream.prototype.type = /* @__PURE__ */ __name(function type(path6) {
24526
+ SendStream.prototype.type = /* @__PURE__ */ __name(function type(path7) {
24527
24527
  var res = this.res;
24528
24528
  if (res.getHeader("Content-Type")) return;
24529
- var type2 = mime.lookup(path6);
24529
+ var type2 = mime.lookup(path7);
24530
24530
  if (!type2) {
24531
24531
  debug("no content-type");
24532
24532
  return;
@@ -24535,9 +24535,9 @@ var require_send = __commonJS({
24535
24535
  debug("content-type %s", type2);
24536
24536
  res.setHeader("Content-Type", type2 + (charset ? "; charset=" + charset : ""));
24537
24537
  }, "type");
24538
- SendStream.prototype.setHeader = /* @__PURE__ */ __name(function setHeader(path6, stat) {
24538
+ SendStream.prototype.setHeader = /* @__PURE__ */ __name(function setHeader(path7, stat) {
24539
24539
  var res = this.res;
24540
- this.emit("headers", res, path6, stat);
24540
+ this.emit("headers", res, path7, stat);
24541
24541
  if (this._acceptRanges && !res.getHeader("Accept-Ranges")) {
24542
24542
  debug("accept ranges");
24543
24543
  res.setHeader("Accept-Ranges", "bytes");
@@ -24604,9 +24604,9 @@ var require_send = __commonJS({
24604
24604
  }) : createError(status, err);
24605
24605
  }
24606
24606
  __name(createHttpError, "createHttpError");
24607
- function decode(path6) {
24607
+ function decode(path7) {
24608
24608
  try {
24609
- return decodeURIComponent(path6);
24609
+ return decodeURIComponent(path7);
24610
24610
  } catch (err) {
24611
24611
  return -1;
24612
24612
  }
@@ -25864,10 +25864,10 @@ var require_utils2 = __commonJS({
25864
25864
  exports2.wetag = createETagGenerator({
25865
25865
  weak: true
25866
25866
  });
25867
- exports2.isAbsolute = function(path5) {
25868
- if ("/" === path5[0]) return true;
25869
- if (":" === path5[1] && ("\\" === path5[2] || "/" === path5[2])) return true;
25870
- if ("\\\\" === path5.substring(0, 2)) return true;
25867
+ exports2.isAbsolute = function(path6) {
25868
+ if ("/" === path6[0]) return true;
25869
+ if (":" === path6[1] && ("\\" === path6[2] || "/" === path6[2])) return true;
25870
+ if ("\\\\" === path6.substring(0, 2)) return true;
25871
25871
  };
25872
25872
  exports2.flatten = deprecate.function(flatten, "utils.flatten: use array-flatten npm module instead");
25873
25873
  exports2.normalizeType = function(type) {
@@ -26083,7 +26083,7 @@ var require_application = __commonJS({
26083
26083
  }, "handle");
26084
26084
  app.use = /* @__PURE__ */ __name(function use(fn) {
26085
26085
  var offset = 0;
26086
- var path5 = "/";
26086
+ var path6 = "/";
26087
26087
  if (typeof fn !== "function") {
26088
26088
  var arg = fn;
26089
26089
  while (Array.isArray(arg) && arg.length !== 0) {
@@ -26091,7 +26091,7 @@ var require_application = __commonJS({
26091
26091
  }
26092
26092
  if (typeof arg !== "function") {
26093
26093
  offset = 1;
26094
- path5 = fn;
26094
+ path6 = fn;
26095
26095
  }
26096
26096
  }
26097
26097
  var fns = flatten(slice.call(arguments, offset));
@@ -26102,12 +26102,12 @@ var require_application = __commonJS({
26102
26102
  var router = this._router;
26103
26103
  fns.forEach(function(fn2) {
26104
26104
  if (!fn2 || !fn2.handle || !fn2.set) {
26105
- return router.use(path5, fn2);
26105
+ return router.use(path6, fn2);
26106
26106
  }
26107
- debug(".use app under %s", path5);
26108
- fn2.mountpath = path5;
26107
+ debug(".use app under %s", path6);
26108
+ fn2.mountpath = path6;
26109
26109
  fn2.parent = this;
26110
- router.use(path5, /* @__PURE__ */ __name(function mounted_app(req, res, next) {
26110
+ router.use(path6, /* @__PURE__ */ __name(function mounted_app(req, res, next) {
26111
26111
  var orig = req.app;
26112
26112
  fn2.handle(req, res, function(err) {
26113
26113
  setPrototypeOf(req, orig.request);
@@ -26119,9 +26119,9 @@ var require_application = __commonJS({
26119
26119
  }, this);
26120
26120
  return this;
26121
26121
  }, "use");
26122
- app.route = /* @__PURE__ */ __name(function route(path5) {
26122
+ app.route = /* @__PURE__ */ __name(function route(path6) {
26123
26123
  this.lazyrouter();
26124
- return this._router.route(path5);
26124
+ return this._router.route(path6);
26125
26125
  }, "route");
26126
26126
  app.engine = /* @__PURE__ */ __name(function engine(ext, fn) {
26127
26127
  if (typeof fn !== "function") {
@@ -26172,7 +26172,7 @@ var require_application = __commonJS({
26172
26172
  }
26173
26173
  return this;
26174
26174
  }, "set");
26175
- app.path = /* @__PURE__ */ __name(function path5() {
26175
+ app.path = /* @__PURE__ */ __name(function path6() {
26176
26176
  return this.parent ? this.parent.path() + this.mountpath : "";
26177
26177
  }, "path");
26178
26178
  app.enabled = /* @__PURE__ */ __name(function enabled(setting) {
@@ -26188,19 +26188,19 @@ var require_application = __commonJS({
26188
26188
  return this.set(setting, false);
26189
26189
  }, "disable");
26190
26190
  methods.forEach(function(method) {
26191
- app[method] = function(path5) {
26191
+ app[method] = function(path6) {
26192
26192
  if (method === "get" && arguments.length === 1) {
26193
- return this.set(path5);
26193
+ return this.set(path6);
26194
26194
  }
26195
26195
  this.lazyrouter();
26196
- var route = this._router.route(path5);
26196
+ var route = this._router.route(path6);
26197
26197
  route[method].apply(route, slice.call(arguments, 1));
26198
26198
  return this;
26199
26199
  };
26200
26200
  });
26201
- app.all = /* @__PURE__ */ __name(function all(path5) {
26201
+ app.all = /* @__PURE__ */ __name(function all(path6) {
26202
26202
  this.lazyrouter();
26203
- var route = this._router.route(path5);
26203
+ var route = this._router.route(path6);
26204
26204
  var args = slice.call(arguments, 1);
26205
26205
  for (var i = 0; i < methods.length; i++) {
26206
26206
  route[methods[i]].apply(route, args);
@@ -27013,7 +27013,7 @@ var require_request = __commonJS({
27013
27013
  ];
27014
27014
  return subdomains2.slice(offset);
27015
27015
  }, "subdomains"));
27016
- defineGetter(req, "path", /* @__PURE__ */ __name(function path5() {
27016
+ defineGetter(req, "path", /* @__PURE__ */ __name(function path6() {
27017
27017
  return parse(this).pathname;
27018
27018
  }, "path"));
27019
27019
  defineGetter(req, "hostname", /* @__PURE__ */ __name(function hostname() {
@@ -27347,7 +27347,7 @@ var require_response = __commonJS({
27347
27347
  var http = require("http");
27348
27348
  var isAbsolute3 = require_utils2().isAbsolute;
27349
27349
  var onFinished = require_on_finished();
27350
- var path5 = require("path");
27350
+ var path6 = require("path");
27351
27351
  var statuses = require_statuses();
27352
27352
  var merge = require_utils_merge();
27353
27353
  var sign = require_cookie_signature().sign;
@@ -27356,9 +27356,9 @@ var require_response = __commonJS({
27356
27356
  var setCharset = require_utils2().setCharset;
27357
27357
  var cookie = require_cookie();
27358
27358
  var send = require_send();
27359
- var extname = path5.extname;
27359
+ var extname = path6.extname;
27360
27360
  var mime = send.mime;
27361
- var resolve = path5.resolve;
27361
+ var resolve = path6.resolve;
27362
27362
  var vary = require_vary();
27363
27363
  var res = Object.create(http.ServerResponse.prototype);
27364
27364
  module2.exports = res;
@@ -27535,26 +27535,26 @@ var require_response = __commonJS({
27535
27535
  this.type("txt");
27536
27536
  return this.send(body);
27537
27537
  }, "sendStatus");
27538
- res.sendFile = /* @__PURE__ */ __name(function sendFile(path6, options, callback) {
27538
+ res.sendFile = /* @__PURE__ */ __name(function sendFile(path7, options, callback) {
27539
27539
  var done = callback;
27540
27540
  var req = this.req;
27541
27541
  var res2 = this;
27542
27542
  var next = req.next;
27543
27543
  var opts = options || {};
27544
- if (!path6) {
27544
+ if (!path7) {
27545
27545
  throw new TypeError("path argument is required to res.sendFile");
27546
27546
  }
27547
- if (typeof path6 !== "string") {
27547
+ if (typeof path7 !== "string") {
27548
27548
  throw new TypeError("path must be a string to res.sendFile");
27549
27549
  }
27550
27550
  if (typeof options === "function") {
27551
27551
  done = options;
27552
27552
  opts = {};
27553
27553
  }
27554
- if (!opts.root && !isAbsolute3(path6)) {
27554
+ if (!opts.root && !isAbsolute3(path7)) {
27555
27555
  throw new TypeError("path must be absolute or specify root to res.sendFile");
27556
27556
  }
27557
- var pathname = encodeURI(path6);
27557
+ var pathname = encodeURI(path7);
27558
27558
  var file = send(req, pathname, opts);
27559
27559
  sendfile(res2, file, opts, function(err) {
27560
27560
  if (done) return done(err);
@@ -27564,7 +27564,7 @@ var require_response = __commonJS({
27564
27564
  }
27565
27565
  });
27566
27566
  }, "sendFile");
27567
- res.sendfile = function(path6, options, callback) {
27567
+ res.sendfile = function(path7, options, callback) {
27568
27568
  var done = callback;
27569
27569
  var req = this.req;
27570
27570
  var res2 = this;
@@ -27574,7 +27574,7 @@ var require_response = __commonJS({
27574
27574
  done = options;
27575
27575
  opts = {};
27576
27576
  }
27577
- var file = send(req, path6, opts);
27577
+ var file = send(req, path7, opts);
27578
27578
  sendfile(res2, file, opts, function(err) {
27579
27579
  if (done) return done(err);
27580
27580
  if (err && err.code === "EISDIR") return next();
@@ -27584,7 +27584,7 @@ var require_response = __commonJS({
27584
27584
  });
27585
27585
  };
27586
27586
  res.sendfile = deprecate.function(res.sendfile, "res.sendfile: Use res.sendFile instead");
27587
- res.download = /* @__PURE__ */ __name(function download(path6, filename, options, callback) {
27587
+ res.download = /* @__PURE__ */ __name(function download(path7, filename, options, callback) {
27588
27588
  var done = callback;
27589
27589
  var name = filename;
27590
27590
  var opts = options || null;
@@ -27601,7 +27601,7 @@ var require_response = __commonJS({
27601
27601
  opts = filename;
27602
27602
  }
27603
27603
  var headers = {
27604
- "Content-Disposition": contentDisposition(name || path6)
27604
+ "Content-Disposition": contentDisposition(name || path7)
27605
27605
  };
27606
27606
  if (opts && opts.headers) {
27607
27607
  var keys = Object.keys(opts.headers);
@@ -27614,7 +27614,7 @@ var require_response = __commonJS({
27614
27614
  }
27615
27615
  opts = Object.create(opts);
27616
27616
  opts.headers = headers;
27617
- var fullPath = !opts.root ? resolve(path6) : path6;
27617
+ var fullPath = !opts.root ? resolve(path7) : path7;
27618
27618
  return this.sendFile(fullPath, opts, done);
27619
27619
  }, "download");
27620
27620
  res.contentType = res.type = /* @__PURE__ */ __name(function contentType(type) {
@@ -27932,11 +27932,11 @@ var require_serve_static = __commonJS({
27932
27932
  }
27933
27933
  var forwardError = !fallthrough;
27934
27934
  var originalUrl = parseUrl.original(req);
27935
- var path5 = parseUrl(req).pathname;
27936
- if (path5 === "/" && originalUrl.pathname.substr(-1) !== "/") {
27937
- path5 = "";
27935
+ var path6 = parseUrl(req).pathname;
27936
+ if (path6 === "/" && originalUrl.pathname.substr(-1) !== "/") {
27937
+ path6 = "";
27938
27938
  }
27939
- var stream = send(req, path5, opts);
27939
+ var stream = send(req, path6, opts);
27940
27940
  stream.on("directory", onDirectory);
27941
27941
  if (setHeaders) {
27942
27942
  stream.on("headers", setHeaders);
@@ -28094,6 +28094,7 @@ __export(index_exports, {
28094
28094
  createCollectLogsMiddleware: () => createCollectLogsMiddleware,
28095
28095
  createDevLogsMiddleware: () => createDevLogsMiddleware,
28096
28096
  createOpenapiMiddleware: () => createOpenapiMiddleware,
28097
+ handleDevProxyError: () => handleDevProxyError,
28097
28098
  normalizeBasePath: () => normalizeBasePath,
28098
28099
  postprocessDrizzleSchema: () => postprocessDrizzleSchema,
28099
28100
  registerMiddlewares: () => registerMiddlewares
@@ -28401,8 +28402,128 @@ function collapseExtraBlankLines(text) {
28401
28402
  }
28402
28403
  __name(collapseExtraBlankLines, "collapseExtraBlankLines");
28403
28404
 
28405
+ // src/helpers/proxy-error/index.ts
28406
+ var import_node_fs2 = __toESM(require("fs"), 1);
28407
+ var import_node_path2 = __toESM(require("path"), 1);
28408
+ var import_node_fs3 = require("fs");
28409
+ var import_node_readline = require("readline");
28410
+ var errorHtmlTemplate = null;
28411
+ function getDirname() {
28412
+ return __dirname;
28413
+ }
28414
+ __name(getDirname, "getDirname");
28415
+ function getErrorHtmlTemplate() {
28416
+ if (!errorHtmlTemplate) {
28417
+ const dirname = getDirname();
28418
+ const htmlPath = import_node_path2.default.join(dirname, "error.html");
28419
+ errorHtmlTemplate = import_node_fs2.default.readFileSync(htmlPath, "utf-8");
28420
+ }
28421
+ return errorHtmlTemplate;
28422
+ }
28423
+ __name(getErrorHtmlTemplate, "getErrorHtmlTemplate");
28424
+ function parseLogLine(line) {
28425
+ const trimmed = line.trim();
28426
+ if (!trimmed) return null;
28427
+ const match = trimmed.match(/^\[\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\]\s+\[server\]\s+(.*)$/);
28428
+ if (match) {
28429
+ return match[1];
28430
+ }
28431
+ return trimmed;
28432
+ }
28433
+ __name(parseLogLine, "parseLogLine");
28434
+ async function readRecentErrorLogs(logDir, maxLogs, fileName) {
28435
+ const logFilePath = import_node_path2.default.join(logDir, fileName);
28436
+ try {
28437
+ await import_node_fs2.default.promises.access(logFilePath);
28438
+ } catch {
28439
+ return [];
28440
+ }
28441
+ const allLines = [];
28442
+ const stream = (0, import_node_fs3.createReadStream)(logFilePath, {
28443
+ encoding: "utf8"
28444
+ });
28445
+ const rl = (0, import_node_readline.createInterface)({
28446
+ input: stream,
28447
+ crlfDelay: Infinity
28448
+ });
28449
+ try {
28450
+ for await (const line of rl) {
28451
+ const parsed = parseLogLine(line);
28452
+ if (parsed !== null) {
28453
+ allLines.push(parsed);
28454
+ }
28455
+ }
28456
+ } finally {
28457
+ rl.close();
28458
+ stream.destroy();
28459
+ }
28460
+ let startIndex = -1;
28461
+ for (let i = allLines.length - 1; i >= 0; i--) {
28462
+ if (allLines[i].includes("dev:server")) {
28463
+ startIndex = i;
28464
+ break;
28465
+ }
28466
+ }
28467
+ if (startIndex === -1) {
28468
+ return [];
28469
+ }
28470
+ let endIndex = allLines.length;
28471
+ for (let i = startIndex; i < allLines.length; i++) {
28472
+ if (/Found \d+ errors?\./.test(allLines[i])) {
28473
+ endIndex = i + 1;
28474
+ break;
28475
+ }
28476
+ }
28477
+ const errorSection = allLines.slice(startIndex, endIndex);
28478
+ if (errorSection.length > maxLogs) {
28479
+ return errorSection.slice(-maxLogs);
28480
+ }
28481
+ return errorSection;
28482
+ }
28483
+ __name(readRecentErrorLogs, "readRecentErrorLogs");
28484
+ function injectErrorData(template, errorLogs) {
28485
+ let logsText = "";
28486
+ if (errorLogs.length > 0) {
28487
+ logsText = errorLogs.join("\n");
28488
+ } else {
28489
+ logsText = "\u672A\u627E\u5230\u76F8\u5173\u9519\u8BEF\u65E5\u5FD7";
28490
+ }
28491
+ return template.replace("{{.errorData.message}}", `\u670D\u52A1\u542F\u52A8\u5F02\u5E38\uFF0C\u8BF7\u6839\u636E\u65E5\u5FD7\u4FEE\u590D\u76F8\u5173\u95EE\u9898
28492
+ ${JSON.stringify(logsText)}`);
28493
+ }
28494
+ __name(injectErrorData, "injectErrorData");
28495
+ function handleDevProxyError(err, _req, res, options) {
28496
+ const { logDir = import_node_path2.default.join(process.cwd(), "logs"), maxErrorLogs = 100, logFileName = "app.log" } = options || {};
28497
+ console.error("[Proxy Error]:", err.message);
28498
+ if (res.headersSent) {
28499
+ console.error("[Proxy Error]: Headers already sent, cannot send error page");
28500
+ return;
28501
+ }
28502
+ (async () => {
28503
+ try {
28504
+ const errorLogs = await readRecentErrorLogs(logDir, maxErrorLogs, logFileName);
28505
+ const template = getErrorHtmlTemplate();
28506
+ const html = injectErrorData(template, errorLogs);
28507
+ res.writeHead(502, {
28508
+ "Content-Type": "text/html; charset=utf-8",
28509
+ "Cache-Control": "no-cache, no-store, must-revalidate"
28510
+ });
28511
+ res.end(html);
28512
+ } catch (error) {
28513
+ console.error("[Proxy Error]: Failed to send error page:", error);
28514
+ if (!res.headersSent) {
28515
+ res.writeHead(502, {
28516
+ "Content-Type": "text/plain; charset=utf-8"
28517
+ });
28518
+ res.end(`Node \u670D\u52A1\u542F\u52A8\u5F02\u5E38\uFF0C\u8BF7\u6839\u636E\u65E5\u5FD7\u4FEE\u590D\u76F8\u5173\u95EE\u9898`);
28519
+ }
28520
+ }
28521
+ })();
28522
+ }
28523
+ __name(handleDevProxyError, "handleDevProxyError");
28524
+
28404
28525
  // src/middlewares/index.ts
28405
- var import_node_path7 = __toESM(require("path"), 1);
28526
+ var import_node_path8 = __toESM(require("path"), 1);
28406
28527
 
28407
28528
  // src/middlewares/openapi/router.ts
28408
28529
  var import_express = __toESM(require_express2(), 1);
@@ -28412,21 +28533,21 @@ var import_promises = __toESM(require("fs/promises"), 1);
28412
28533
  var import_node_crypto = __toESM(require("crypto"), 1);
28413
28534
 
28414
28535
  // src/middlewares/openapi/services.ts
28415
- var import_node_fs3 = require("fs");
28416
- var import_node_path3 = __toESM(require("path"), 1);
28536
+ var import_node_fs5 = require("fs");
28537
+ var import_node_path4 = __toESM(require("path"), 1);
28417
28538
  var import_typescript = __toESM(require("typescript"), 1);
28418
28539
 
28419
28540
  // src/middlewares/openapi/utils.ts
28420
- var import_node_path2 = __toESM(require("path"), 1);
28421
- var import_node_fs2 = require("fs");
28541
+ var import_node_path3 = __toESM(require("path"), 1);
28542
+ var import_node_fs4 = require("fs");
28422
28543
  async function findControllerFiles(dir) {
28423
28544
  const files = [];
28424
28545
  async function scan(currentDir) {
28425
- const entries = await import_node_fs2.promises.readdir(currentDir, {
28546
+ const entries = await import_node_fs4.promises.readdir(currentDir, {
28426
28547
  withFileTypes: true
28427
28548
  });
28428
28549
  for (const entry of entries) {
28429
- const fullPath = import_node_path2.default.join(currentDir, entry.name);
28550
+ const fullPath = import_node_path3.default.join(currentDir, entry.name);
28430
28551
  if (entry.isDirectory()) {
28431
28552
  await scan(fullPath);
28432
28553
  } else if (entry.isFile() && entry.name.endsWith(".controller.ts")) {
@@ -28499,21 +28620,21 @@ __name(transformOpenapiPaths, "transformOpenapiPaths");
28499
28620
  // src/middlewares/openapi/services.ts
28500
28621
  async function enhanceOpenApiWithSourceInfo(options = {}) {
28501
28622
  const startTime = Date.now();
28502
- const openapiPath = options.openapiPath || import_node_path3.default.resolve(__dirname, "../client/src/api/gen/openapi.json");
28503
- const serverDir = options.serverDir || import_node_path3.default.resolve(__dirname, "../server");
28623
+ const openapiPath = options.openapiPath || import_node_path4.default.resolve(__dirname, "../client/src/api/gen/openapi.json");
28624
+ const serverDir = options.serverDir || import_node_path4.default.resolve(__dirname, "../server");
28504
28625
  const writeFile = options.writeFile !== false;
28505
28626
  let openapi;
28506
28627
  if (options.openapiData) {
28507
28628
  openapi = JSON.parse(JSON.stringify(options.openapiData));
28508
28629
  } else {
28509
- const openapiContent = await import_node_fs3.promises.readFile(openapiPath, "utf-8");
28630
+ const openapiContent = await import_node_fs5.promises.readFile(openapiPath, "utf-8");
28510
28631
  openapi = JSON.parse(openapiContent);
28511
28632
  }
28512
28633
  const controllerFiles = await findControllerFiles(serverDir);
28513
28634
  const sourceMap = await buildSourceMap(controllerFiles, processControllerFile);
28514
28635
  const enhanced = enhanceOpenApiPaths(openapi, sourceMap);
28515
28636
  if (writeFile) {
28516
- await import_node_fs3.promises.writeFile(openapiPath, JSON.stringify(openapi, null, 2) + "\n", "utf-8");
28637
+ await import_node_fs5.promises.writeFile(openapiPath, JSON.stringify(openapi, null, 2) + "\n", "utf-8");
28517
28638
  }
28518
28639
  const duration = Date.now() - startTime;
28519
28640
  return {
@@ -28528,8 +28649,8 @@ async function enhanceOpenApiWithSourceInfo(options = {}) {
28528
28649
  }
28529
28650
  __name(enhanceOpenApiWithSourceInfo, "enhanceOpenApiWithSourceInfo");
28530
28651
  async function processControllerFile(filePath) {
28531
- const relativePath = import_node_path3.default.relative(process.cwd(), filePath);
28532
- const content = await import_node_fs3.promises.readFile(filePath, "utf-8");
28652
+ const relativePath = import_node_path4.default.relative(process.cwd(), filePath);
28653
+ const content = await import_node_fs5.promises.readFile(filePath, "utf-8");
28533
28654
  const sourceFile = import_typescript.default.createSourceFile(filePath, content, import_typescript.default.ScriptTarget.Latest, true);
28534
28655
  return extractControllerMetadata(sourceFile, relativePath);
28535
28656
  }
@@ -28689,8 +28810,8 @@ __name(createOpenapiMiddleware, "createOpenapiMiddleware");
28689
28810
  var import_express2 = __toESM(require_express2(), 1);
28690
28811
 
28691
28812
  // src/middlewares/dev-logs/utils.ts
28692
- var import_node_fs4 = require("fs");
28693
- var import_node_path4 = require("path");
28813
+ var import_node_fs6 = require("fs");
28814
+ var import_node_path5 = require("path");
28694
28815
 
28695
28816
  // src/middlewares/dev-logs/helper/path-matcher.ts
28696
28817
  function pathPatternToRegex(pattern) {
@@ -28722,33 +28843,33 @@ function hasSpecialPatterns(pattern) {
28722
28843
  return /[{*]/.test(pattern);
28723
28844
  }
28724
28845
  __name(hasSpecialPatterns, "hasSpecialPatterns");
28725
- function normalizePathForMatching(path5) {
28726
- return path5.replace(/\/+/g, "/").replace(/\/+$/, "");
28846
+ function normalizePathForMatching(path6) {
28847
+ return path6.replace(/\/+/g, "/").replace(/\/+$/, "");
28727
28848
  }
28728
28849
  __name(normalizePathForMatching, "normalizePathForMatching");
28729
28850
 
28730
28851
  // src/middlewares/dev-logs/utils.ts
28731
28852
  function resolveLogDir(provided) {
28732
28853
  if (!provided) {
28733
- return (0, import_node_path4.join)(process.cwd(), "logs");
28854
+ return (0, import_node_path5.join)(process.cwd(), "logs");
28734
28855
  }
28735
- return (0, import_node_path4.isAbsolute)(provided) ? provided : (0, import_node_path4.join)(process.cwd(), provided);
28856
+ return (0, import_node_path5.isAbsolute)(provided) ? provided : (0, import_node_path5.join)(process.cwd(), provided);
28736
28857
  }
28737
28858
  __name(resolveLogDir, "resolveLogDir");
28738
28859
  function getRelativePath(filePath) {
28739
- return (0, import_node_path4.relative)(process.cwd(), filePath);
28860
+ return (0, import_node_path5.relative)(process.cwd(), filePath);
28740
28861
  }
28741
28862
  __name(getRelativePath, "getRelativePath");
28742
28863
  async function fileExists(filePath) {
28743
28864
  try {
28744
- await import_node_fs4.promises.access(filePath);
28865
+ await import_node_fs6.promises.access(filePath);
28745
28866
  return true;
28746
28867
  } catch {
28747
28868
  return false;
28748
28869
  }
28749
28870
  }
28750
28871
  __name(fileExists, "fileExists");
28751
- function parseLogLine(line) {
28872
+ function parseLogLine2(line) {
28752
28873
  const trimmed = line.trim();
28753
28874
  if (!trimmed) return void 0;
28754
28875
  try {
@@ -28757,7 +28878,7 @@ function parseLogLine(line) {
28757
28878
  return void 0;
28758
28879
  }
28759
28880
  }
28760
- __name(parseLogLine, "parseLogLine");
28881
+ __name(parseLogLine2, "parseLogLine");
28761
28882
  function extractNumber(message, pattern) {
28762
28883
  if (typeof message !== "string") return void 0;
28763
28884
  const match = message.match(pattern);
@@ -28791,8 +28912,8 @@ function resolveLogFilePath(baseDir, fileName) {
28791
28912
  if (segments.some((segment) => segment === "..")) {
28792
28913
  throw new Error("Invalid log file path");
28793
28914
  }
28794
- const resolved = (0, import_node_path4.join)(baseDir, segments.join("/"));
28795
- const rel = (0, import_node_path4.relative)(baseDir, resolved);
28915
+ const resolved = (0, import_node_path5.join)(baseDir, segments.join("/"));
28916
+ const rel = (0, import_node_path5.relative)(baseDir, resolved);
28796
28917
  if (rel.startsWith("..")) {
28797
28918
  throw new Error("Access to the specified log file is denied");
28798
28919
  }
@@ -28821,26 +28942,26 @@ function serializeError(error) {
28821
28942
  __name(serializeError, "serializeError");
28822
28943
 
28823
28944
  // src/middlewares/dev-logs/controller.ts
28824
- var import_node_path5 = require("path");
28945
+ var import_node_path6 = require("path");
28825
28946
 
28826
28947
  // src/middlewares/dev-logs/services.ts
28827
- var import_node_fs5 = require("fs");
28828
- var import_node_readline = require("readline");
28948
+ var import_node_fs7 = require("fs");
28949
+ var import_node_readline2 = require("readline");
28829
28950
  async function readLogEntriesByTrace(filePath, traceId, limit) {
28830
28951
  const exists = await fileExists(filePath);
28831
28952
  if (!exists) {
28832
28953
  return void 0;
28833
28954
  }
28834
28955
  const matches = [];
28835
- const stream = (0, import_node_fs5.createReadStream)(filePath, {
28956
+ const stream = (0, import_node_fs7.createReadStream)(filePath, {
28836
28957
  encoding: "utf8"
28837
28958
  });
28838
- const rl = (0, import_node_readline.createInterface)({
28959
+ const rl = (0, import_node_readline2.createInterface)({
28839
28960
  input: stream,
28840
28961
  crlfDelay: Infinity
28841
28962
  });
28842
28963
  for await (const line of rl) {
28843
- const entry = parseLogLine(line);
28964
+ const entry = parseLogLine2(line);
28844
28965
  if (!entry) continue;
28845
28966
  if (entry.trace_id !== traceId) continue;
28846
28967
  matches.push(entry);
@@ -28914,7 +29035,7 @@ async function readRecentTraceCalls(filePath, page, pageSize, pathFilter, method
28914
29035
  }
28915
29036
  }, "processLogEntry");
28916
29037
  const processLine = /* @__PURE__ */ __name((line) => {
28917
- const entry = parseLogLine(line);
29038
+ const entry = parseLogLine2(line);
28918
29039
  if (entry?.trace_id) {
28919
29040
  processLogEntry(entry);
28920
29041
  }
@@ -28924,7 +29045,7 @@ async function readRecentTraceCalls(filePath, page, pageSize, pathFilter, method
28924
29045
  }
28925
29046
  __name(readRecentTraceCalls, "readRecentTraceCalls");
28926
29047
  async function readFileReverse(filePath, chunkSize, processLine) {
28927
- const handle = await import_node_fs5.promises.open(filePath, "r");
29048
+ const handle = await import_node_fs7.promises.open(filePath, "r");
28928
29049
  try {
28929
29050
  const stats = await handle.stat();
28930
29051
  let position = stats.size;
@@ -28986,10 +29107,10 @@ async function readLogFilePage(filePath, page, pageSize) {
28986
29107
  const capacity = page * pageSize;
28987
29108
  const buffer = [];
28988
29109
  let totalLines = 0;
28989
- const stream = (0, import_node_fs5.createReadStream)(filePath, {
29110
+ const stream = (0, import_node_fs7.createReadStream)(filePath, {
28990
29111
  encoding: "utf8"
28991
29112
  });
28992
- const rl = (0, import_node_readline.createInterface)({
29113
+ const rl = (0, import_node_readline2.createInterface)({
28993
29114
  input: stream,
28994
29115
  crlfDelay: Infinity
28995
29116
  });
@@ -29050,7 +29171,7 @@ function handleError(res, error, message = "Failed to read log file") {
29050
29171
  }
29051
29172
  __name(handleError, "handleError");
29052
29173
  function createGetTraceEntriesHandler(logDir) {
29053
- const appLogPath = (0, import_node_path5.join)(logDir, "app.log");
29174
+ const appLogPath = (0, import_node_path6.join)(logDir, "app.log");
29054
29175
  return async (req, res) => {
29055
29176
  const traceId = (req.params.traceId || "").trim();
29056
29177
  if (!traceId) {
@@ -29077,7 +29198,7 @@ function createGetTraceEntriesHandler(logDir) {
29077
29198
  }
29078
29199
  __name(createGetTraceEntriesHandler, "createGetTraceEntriesHandler");
29079
29200
  function createGetRecentTracesHandler(logDir) {
29080
- const traceLogPath = (0, import_node_path5.join)(logDir, "trace.log");
29201
+ const traceLogPath = (0, import_node_path6.join)(logDir, "trace.log");
29081
29202
  return async (req, res) => {
29082
29203
  const page = parsePositiveInt(req.query.page, 1);
29083
29204
  const pageSize = parseLimit(req.query.pageSize, 10, 100);
@@ -29181,18 +29302,18 @@ var import_path = require("path");
29181
29302
  var import_fs = __toESM(require("fs"), 1);
29182
29303
 
29183
29304
  // src/middlewares/collect-logs/utils.ts
29184
- var import_node_path6 = require("path");
29185
- var import_node_fs6 = __toESM(require("fs"), 1);
29305
+ var import_node_path7 = require("path");
29306
+ var import_node_fs8 = __toESM(require("fs"), 1);
29186
29307
  function resolveLogDir2(provided) {
29187
29308
  if (!provided) {
29188
- return (0, import_node_path6.join)(process.cwd(), "logs");
29309
+ return (0, import_node_path7.join)(process.cwd(), "logs");
29189
29310
  }
29190
- return (0, import_node_path6.isAbsolute)(provided) ? provided : (0, import_node_path6.join)(process.cwd(), provided);
29311
+ return (0, import_node_path7.isAbsolute)(provided) ? provided : (0, import_node_path7.join)(process.cwd(), provided);
29191
29312
  }
29192
29313
  __name(resolveLogDir2, "resolveLogDir");
29193
29314
  function ensureDir(dir) {
29194
- if (!import_node_fs6.default.existsSync(dir)) {
29195
- import_node_fs6.default.mkdirSync(dir, {
29315
+ if (!import_node_fs8.default.existsSync(dir)) {
29316
+ import_node_fs8.default.mkdirSync(dir, {
29196
29317
  recursive: true
29197
29318
  });
29198
29319
  }
@@ -29215,7 +29336,15 @@ function collectLogsHandler(logDir, fileName) {
29215
29336
  return async (req, res) => {
29216
29337
  try {
29217
29338
  const logContent = req.body;
29218
- const logLine = JSON.stringify(logContent) + "\n";
29339
+ if (!logContent.message) {
29340
+ return res.status(400).json({
29341
+ message: "message is required"
29342
+ });
29343
+ }
29344
+ const logLine = JSON.stringify({
29345
+ ...logContent,
29346
+ server_time: (/* @__PURE__ */ new Date()).toISOString()
29347
+ }) + "\n";
29219
29348
  await import_fs.default.promises.appendFile(filePath, logLine);
29220
29349
  res.json({
29221
29350
  success: true
@@ -29239,7 +29368,10 @@ function collectLogsBatchHandler(logDir, fileName) {
29239
29368
  }
29240
29369
  const logLines = [];
29241
29370
  for (const logContent of logContents) {
29242
- logLines.push(JSON.stringify(logContent) + "\n");
29371
+ logLines.push(JSON.stringify({
29372
+ ...logContent,
29373
+ server_time: (/* @__PURE__ */ new Date()).toISOString()
29374
+ }) + "\n");
29243
29375
  }
29244
29376
  await import_fs.default.promises.appendFile(filePath, logLines.join(""));
29245
29377
  res.json({
@@ -29304,7 +29436,7 @@ function isGlobalMiddleware(middleware) {
29304
29436
  }
29305
29437
  __name(isGlobalMiddleware, "isGlobalMiddleware");
29306
29438
  function computeMountPath(basePath, mountPath) {
29307
- const routePath = import_node_path7.default.posix.join(basePath, mountPath);
29439
+ const routePath = import_node_path8.default.posix.join(basePath, mountPath);
29308
29440
  return routePath.startsWith("/") ? routePath : `/${routePath}`;
29309
29441
  }
29310
29442
  __name(computeMountPath, "computeMountPath");
@@ -29312,7 +29444,7 @@ function logMiddlewareRegistration(middleware, fullMountPath) {
29312
29444
  if (middleware.routes && middleware.routes.length > 0) {
29313
29445
  console.log(`[Middleware] Registered: ${middleware.name} at ${fullMountPath}`);
29314
29446
  middleware.routes.forEach((route) => {
29315
- const routePath = route.path === "/" ? fullMountPath : import_node_path7.default.posix.join(fullMountPath, route.path);
29447
+ const routePath = route.path === "/" ? fullMountPath : import_node_path8.default.posix.join(fullMountPath, route.path);
29316
29448
  console.log(` ${route.method} ${routePath} - ${route.description}`);
29317
29449
  });
29318
29450
  } else {
@@ -29375,6 +29507,7 @@ __name(registerMiddlewares, "registerMiddlewares");
29375
29507
  createCollectLogsMiddleware,
29376
29508
  createDevLogsMiddleware,
29377
29509
  createOpenapiMiddleware,
29510
+ handleDevProxyError,
29378
29511
  normalizeBasePath,
29379
29512
  postprocessDrizzleSchema,
29380
29513
  registerMiddlewares