@lark-apaas/devtool-kits 0.1.0-alpha.1 → 0.1.0-alpha.10
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/README.md +383 -185
- package/dist/error.html +345 -0
- package/dist/index.cjs +509 -245
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +57 -3
- package/dist/index.d.ts +57 -3
- package/dist/index.js +857 -595
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1370,8 +1370,8 @@ var require_node = __commonJS({
|
|
|
1370
1370
|
}
|
|
1371
1371
|
break;
|
|
1372
1372
|
case "FILE":
|
|
1373
|
-
var
|
|
1374
|
-
stream2 = new
|
|
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(
|
|
17563
|
-
if (!
|
|
17562
|
+
function lookup(path6) {
|
|
17563
|
+
if (!path6 || typeof path6 !== "string") {
|
|
17564
17564
|
return false;
|
|
17565
17565
|
}
|
|
17566
|
-
var extension2 = extname("x." +
|
|
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
|
|
21254
|
-
stream2 = new
|
|
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
|
|
22024
|
-
stream2 = new
|
|
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(
|
|
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 (
|
|
22136
|
-
while (m = MATCHING_GROUP_REGEXP.exec(
|
|
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
|
|
22144
|
+
return path6;
|
|
22145
22145
|
}
|
|
22146
|
-
if (Array.isArray(
|
|
22147
|
-
|
|
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(
|
|
22150
|
+
return new RegExp(path6.join("|"), flags);
|
|
22151
22151
|
}
|
|
22152
|
-
if (typeof
|
|
22152
|
+
if (typeof path6 !== "string") {
|
|
22153
22153
|
throw new TypeError("path must be a string, array of strings, or regular expression");
|
|
22154
22154
|
}
|
|
22155
|
-
|
|
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 +=
|
|
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(
|
|
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
|
-
|
|
22208
|
+
path6 += strict ? "" : path6[path6.length - 1] === "/" ? "?" : "/?";
|
|
22209
22209
|
if (end) {
|
|
22210
|
-
|
|
22211
|
-
} else if (
|
|
22212
|
-
|
|
22210
|
+
path6 += "$";
|
|
22211
|
+
} else if (path6[path6.length - 1] !== "/") {
|
|
22212
|
+
path6 += lookahead ? "(?=/|$)" : "(?:/|$)";
|
|
22213
22213
|
}
|
|
22214
|
-
return new RegExp("^" +
|
|
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(
|
|
22228
|
+
function Layer(path6, options, fn) {
|
|
22229
22229
|
if (!(this instanceof Layer)) {
|
|
22230
|
-
return new Layer(
|
|
22230
|
+
return new Layer(path6, options, fn);
|
|
22231
22231
|
}
|
|
22232
|
-
debug("new %o",
|
|
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(
|
|
22239
|
-
this.regexp.fast_star =
|
|
22240
|
-
this.regexp.fast_slash =
|
|
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(
|
|
22265
|
+
Layer.prototype.match = /* @__PURE__ */ __name(function match(path6) {
|
|
22266
22266
|
var match2;
|
|
22267
|
-
if (
|
|
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(
|
|
22275
|
+
"0": decode_param(path6)
|
|
22276
22276
|
};
|
|
22277
|
-
this.path =
|
|
22277
|
+
this.path = path6;
|
|
22278
22278
|
return true;
|
|
22279
22279
|
}
|
|
22280
|
-
match2 = this.regexp.exec(
|
|
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(
|
|
22377
|
-
this.path =
|
|
22376
|
+
function Route(path6) {
|
|
22377
|
+
this.path = path6;
|
|
22378
22378
|
this.stack = [];
|
|
22379
|
-
debug("new %o",
|
|
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
|
|
22596
|
-
if (
|
|
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,
|
|
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,
|
|
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,
|
|
22648
|
+
function trim_prefix(layer, layerError, layerPath, path6) {
|
|
22649
22649
|
if (layerPath.length !== 0) {
|
|
22650
|
-
if (layerPath !==
|
|
22650
|
+
if (layerPath !== path6.slice(0, layerPath.length)) {
|
|
22651
22651
|
next(layerError);
|
|
22652
22652
|
return;
|
|
22653
22653
|
}
|
|
22654
|
-
var c =
|
|
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
|
|
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
|
-
|
|
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",
|
|
22756
|
-
var layer = new Layer(
|
|
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(
|
|
22767
|
-
var route2 = new Route(
|
|
22768
|
-
var layer = new Layer(
|
|
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(
|
|
22779
|
-
var route = this.route(
|
|
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,
|
|
22819
|
+
function matchLayer(layer, path6) {
|
|
22820
22820
|
try {
|
|
22821
|
-
return layer.match(
|
|
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
|
|
22945
|
-
var
|
|
22946
|
-
var dirname =
|
|
22947
|
-
var basename =
|
|
22948
|
-
var extname =
|
|
22949
|
-
var
|
|
22950
|
-
var 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
|
|
22980
|
+
var path7;
|
|
22981
22981
|
var roots = [].concat(this.root);
|
|
22982
22982
|
debug('lookup "%s"', name);
|
|
22983
|
-
for (var i = 0; i < roots.length && !
|
|
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
|
-
|
|
22988
|
+
path7 = this.resolve(dir, file);
|
|
22989
22989
|
}
|
|
22990
|
-
return
|
|
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
|
|
22999
|
-
var stat = tryStat(
|
|
22998
|
+
var path7 = join5(dir, file);
|
|
22999
|
+
var stat = tryStat(path7);
|
|
23000
23000
|
if (stat && stat.isFile()) {
|
|
23001
|
-
return
|
|
23001
|
+
return path7;
|
|
23002
23002
|
}
|
|
23003
|
-
|
|
23004
|
-
stat = tryStat(
|
|
23003
|
+
path7 = join5(dir, basename(file, ext), "index" + ext);
|
|
23004
|
+
stat = tryStat(path7);
|
|
23005
23005
|
if (stat && stat.isFile()) {
|
|
23006
|
-
return
|
|
23006
|
+
return path7;
|
|
23007
23007
|
}
|
|
23008
23008
|
}, "resolve");
|
|
23009
|
-
function tryStat(
|
|
23010
|
-
debug('stat "%s"',
|
|
23009
|
+
function tryStat(path7) {
|
|
23010
|
+
debug('stat "%s"', path7);
|
|
23011
23011
|
try {
|
|
23012
|
-
return
|
|
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
|
|
23662
|
-
stream2 = new
|
|
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
|
|
23863
|
-
var
|
|
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 =
|
|
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(
|
|
23894
|
-
var ext =
|
|
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
|
|
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
|
|
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 =
|
|
24140
|
-
var
|
|
24141
|
-
var normalize =
|
|
24142
|
-
var resolve =
|
|
24143
|
-
var 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,
|
|
24150
|
-
return new SendStream(req,
|
|
24149
|
+
function send(req, path7, options) {
|
|
24150
|
+
return new SendStream(req, path7, options);
|
|
24151
24151
|
}
|
|
24152
24152
|
__name(send, "send");
|
|
24153
|
-
function SendStream(req,
|
|
24153
|
+
function SendStream(req, path7, options) {
|
|
24154
24154
|
Stream.call(this);
|
|
24155
24155
|
var opts = options || {};
|
|
24156
24156
|
this.options = opts;
|
|
24157
|
-
this.path =
|
|
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(
|
|
24207
|
-
this._root = resolve(String(
|
|
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(
|
|
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,
|
|
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
|
|
24338
|
-
if (
|
|
24337
|
+
var path7 = decode(this.path);
|
|
24338
|
+
if (path7 === -1) {
|
|
24339
24339
|
this.error(400);
|
|
24340
24340
|
return res;
|
|
24341
24341
|
}
|
|
24342
|
-
if (~
|
|
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 (
|
|
24349
|
-
|
|
24348
|
+
if (path7) {
|
|
24349
|
+
path7 = normalize("." + sep + path7);
|
|
24350
24350
|
}
|
|
24351
|
-
if (UP_PATH_REGEXP.test(
|
|
24352
|
-
debug('malicious path "%s"',
|
|
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 =
|
|
24357
|
-
|
|
24356
|
+
parts = path7.split(sep);
|
|
24357
|
+
path7 = normalize(join5(root, path7));
|
|
24358
24358
|
} else {
|
|
24359
|
-
if (UP_PATH_REGEXP.test(
|
|
24360
|
-
debug('malicious path "%s"',
|
|
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(
|
|
24365
|
-
|
|
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,
|
|
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(
|
|
24386
|
+
this.sendIndex(path7);
|
|
24387
24387
|
return res;
|
|
24388
24388
|
}
|
|
24389
|
-
this.sendFile(
|
|
24389
|
+
this.sendFile(path7);
|
|
24390
24390
|
return res;
|
|
24391
24391
|
}, "pipe");
|
|
24392
|
-
SendStream.prototype.send = /* @__PURE__ */ __name(function send2(
|
|
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"',
|
|
24405
|
-
this.setHeader(
|
|
24406
|
-
this.type(
|
|
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(
|
|
24457
|
+
this.stream(path7, opts);
|
|
24458
24458
|
}, "send");
|
|
24459
|
-
SendStream.prototype.sendFile = /* @__PURE__ */ __name(function sendFile(
|
|
24459
|
+
SendStream.prototype.sendFile = /* @__PURE__ */ __name(function sendFile(path7) {
|
|
24460
24460
|
var i = 0;
|
|
24461
24461
|
var self = this;
|
|
24462
|
-
debug('stat "%s"',
|
|
24463
|
-
|
|
24464
|
-
if (err && err.code === "ENOENT" && !extname(
|
|
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(
|
|
24469
|
-
self.emit("file",
|
|
24470
|
-
self.send(
|
|
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 =
|
|
24476
|
+
var p = path7 + "." + self._extensions[i++];
|
|
24477
24477
|
debug('stat "%s"', p);
|
|
24478
|
-
|
|
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(
|
|
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 =
|
|
24495
|
+
var p = join5(path7, self._index[i]);
|
|
24496
24496
|
debug('stat "%s"', p);
|
|
24497
|
-
|
|
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(
|
|
24507
|
+
SendStream.prototype.stream = /* @__PURE__ */ __name(function stream(path7, options) {
|
|
24508
24508
|
var self = this;
|
|
24509
24509
|
var res = this.res;
|
|
24510
|
-
var stream2 =
|
|
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(
|
|
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(
|
|
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(
|
|
24538
|
+
SendStream.prototype.setHeader = /* @__PURE__ */ __name(function setHeader(path7, stat) {
|
|
24539
24539
|
var res = this.res;
|
|
24540
|
-
this.emit("headers", res,
|
|
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(
|
|
24607
|
+
function decode(path7) {
|
|
24608
24608
|
try {
|
|
24609
|
-
return decodeURIComponent(
|
|
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(
|
|
25868
|
-
if ("/" ===
|
|
25869
|
-
if (":" ===
|
|
25870
|
-
if ("\\\\" ===
|
|
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
|
|
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
|
-
|
|
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(
|
|
26105
|
+
return router.use(path6, fn2);
|
|
26106
26106
|
}
|
|
26107
|
-
debug(".use app under %s",
|
|
26108
|
-
fn2.mountpath =
|
|
26107
|
+
debug(".use app under %s", path6);
|
|
26108
|
+
fn2.mountpath = path6;
|
|
26109
26109
|
fn2.parent = this;
|
|
26110
|
-
router.use(
|
|
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(
|
|
26122
|
+
app.route = /* @__PURE__ */ __name(function route(path6) {
|
|
26123
26123
|
this.lazyrouter();
|
|
26124
|
-
return this._router.route(
|
|
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
|
|
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(
|
|
26191
|
+
app[method] = function(path6) {
|
|
26192
26192
|
if (method === "get" && arguments.length === 1) {
|
|
26193
|
-
return this.set(
|
|
26193
|
+
return this.set(path6);
|
|
26194
26194
|
}
|
|
26195
26195
|
this.lazyrouter();
|
|
26196
|
-
var route = this._router.route(
|
|
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(
|
|
26201
|
+
app.all = /* @__PURE__ */ __name(function all(path6) {
|
|
26202
26202
|
this.lazyrouter();
|
|
26203
|
-
var route = this._router.route(
|
|
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
|
|
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() {
|
|
@@ -27345,9 +27345,9 @@ var require_response = __commonJS({
|
|
|
27345
27345
|
var encodeUrl = require_encodeurl();
|
|
27346
27346
|
var escapeHtml = require_escape_html();
|
|
27347
27347
|
var http = require("http");
|
|
27348
|
-
var
|
|
27348
|
+
var isAbsolute3 = require_utils2().isAbsolute;
|
|
27349
27349
|
var onFinished = require_on_finished();
|
|
27350
|
-
var
|
|
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 =
|
|
27359
|
+
var extname = path6.extname;
|
|
27360
27360
|
var mime = send.mime;
|
|
27361
|
-
var 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(
|
|
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 (!
|
|
27544
|
+
if (!path7) {
|
|
27545
27545
|
throw new TypeError("path argument is required to res.sendFile");
|
|
27546
27546
|
}
|
|
27547
|
-
if (typeof
|
|
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 && !
|
|
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(
|
|
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(
|
|
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,
|
|
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(
|
|
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 ||
|
|
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(
|
|
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
|
|
27936
|
-
if (
|
|
27937
|
-
|
|
27935
|
+
var path6 = parseUrl(req).pathname;
|
|
27936
|
+
if (path6 === "/" && originalUrl.pathname.substr(-1) !== "/") {
|
|
27937
|
+
path6 = "";
|
|
27938
27938
|
}
|
|
27939
|
-
var stream = send(req,
|
|
27939
|
+
var stream = send(req, path6, opts);
|
|
27940
27940
|
stream.on("directory", onDirectory);
|
|
27941
27941
|
if (setHeaders) {
|
|
27942
27942
|
stream.on("headers", setHeaders);
|
|
@@ -28091,8 +28091,10 @@ var require_express2 = __commonJS({
|
|
|
28091
28091
|
// src/index.ts
|
|
28092
28092
|
var index_exports = {};
|
|
28093
28093
|
__export(index_exports, {
|
|
28094
|
+
createCollectLogsMiddleware: () => createCollectLogsMiddleware,
|
|
28094
28095
|
createDevLogsMiddleware: () => createDevLogsMiddleware,
|
|
28095
28096
|
createOpenapiMiddleware: () => createOpenapiMiddleware,
|
|
28097
|
+
handleDevProxyError: () => handleDevProxyError,
|
|
28096
28098
|
normalizeBasePath: () => normalizeBasePath,
|
|
28097
28099
|
postprocessDrizzleSchema: () => postprocessDrizzleSchema,
|
|
28098
28100
|
registerMiddlewares: () => registerMiddlewares
|
|
@@ -28111,9 +28113,8 @@ __name(normalizeBasePath, "normalizeBasePath");
|
|
|
28111
28113
|
var import_node_fs = __toESM(require("fs"), 1);
|
|
28112
28114
|
var import_node_path = __toESM(require("path"), 1);
|
|
28113
28115
|
var import_pinyin_pro = require("pinyin-pro");
|
|
28114
|
-
var USER_PROFILE_MARKER = "// TODO: failed to parse database type 'user_profile'";
|
|
28115
|
-
var FILE_ATTACHMENT_MARKER = "// TODO: failed to parse database type 'file_attachment'";
|
|
28116
28116
|
var HEADER_COMMENT = "/** auto generated, do not edit */";
|
|
28117
|
+
var CUSTOM_TYPE_PATTERN = /\/\/ TODO: failed to parse database type '(?:\w+\.)?(user_profile|file_attachment)(\[\])?'/;
|
|
28117
28118
|
function postprocessDrizzleSchema(targetPath) {
|
|
28118
28119
|
const resolvedPath = import_node_path.default.resolve(targetPath);
|
|
28119
28120
|
if (!import_node_fs.default.existsSync(resolvedPath)) {
|
|
@@ -28144,6 +28145,9 @@ function postprocessDrizzleSchema(targetPath) {
|
|
|
28144
28145
|
console.warn("[postprocess-drizzle-schema] Unmatched custom types:", replacement.unmatched.length);
|
|
28145
28146
|
replacement.unmatched.forEach((line) => console.warn(` ${line}`));
|
|
28146
28147
|
}
|
|
28148
|
+
if (tableConversion.converted > 0) {
|
|
28149
|
+
console.info(`[postprocess-drizzle-schema] Converted ${tableConversion.converted} schema.table invocations to pgTable`);
|
|
28150
|
+
}
|
|
28147
28151
|
return {
|
|
28148
28152
|
replacedUnknown: replacement.replaced,
|
|
28149
28153
|
unmatchedUnknown: replacement.unmatched
|
|
@@ -28258,25 +28262,18 @@ function replaceUnknownColumns(source) {
|
|
|
28258
28262
|
const unmatched = [];
|
|
28259
28263
|
for (let i = 0; i < lines.length; i += 1) {
|
|
28260
28264
|
const line = lines[i];
|
|
28261
|
-
|
|
28262
|
-
|
|
28263
|
-
|
|
28264
|
-
|
|
28265
|
-
|
|
28266
|
-
i += 1;
|
|
28267
|
-
} else {
|
|
28268
|
-
unmatched.push(line.trim());
|
|
28269
|
-
}
|
|
28270
|
-
continue;
|
|
28271
|
-
}
|
|
28272
|
-
if (line.includes(FILE_ATTACHMENT_MARKER)) {
|
|
28273
|
-
const replacedLine = replaceFollowingUnknown(lines[i + 1], "fileAttachment");
|
|
28265
|
+
const match = line.match(CUSTOM_TYPE_PATTERN);
|
|
28266
|
+
if (match) {
|
|
28267
|
+
const typeName = match[1];
|
|
28268
|
+
const factory = typeName === "user_profile" ? "userProfile" : "fileAttachment";
|
|
28269
|
+
const replacedLine = replaceFollowingUnknown(lines[i + 1], factory);
|
|
28274
28270
|
if (replacedLine) {
|
|
28275
28271
|
result.push(replacedLine);
|
|
28276
28272
|
replaced += 1;
|
|
28277
28273
|
i += 1;
|
|
28278
28274
|
} else {
|
|
28279
28275
|
unmatched.push(line.trim());
|
|
28276
|
+
result.push(line);
|
|
28280
28277
|
}
|
|
28281
28278
|
continue;
|
|
28282
28279
|
}
|
|
@@ -28404,13 +28401,129 @@ function collapseExtraBlankLines(text) {
|
|
|
28404
28401
|
return text.replace(/\n{3,}/g, "\n\n");
|
|
28405
28402
|
}
|
|
28406
28403
|
__name(collapseExtraBlankLines, "collapseExtraBlankLines");
|
|
28407
|
-
|
|
28408
|
-
|
|
28409
|
-
|
|
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;
|
|
28410
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('message: "{{.errorData.message}}"', `message: server \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");
|
|
28411
28524
|
|
|
28412
28525
|
// src/middlewares/index.ts
|
|
28413
|
-
var
|
|
28526
|
+
var import_node_path8 = __toESM(require("path"), 1);
|
|
28414
28527
|
|
|
28415
28528
|
// src/middlewares/openapi/router.ts
|
|
28416
28529
|
var import_express = __toESM(require_express2(), 1);
|
|
@@ -28420,21 +28533,21 @@ var import_promises = __toESM(require("fs/promises"), 1);
|
|
|
28420
28533
|
var import_node_crypto = __toESM(require("crypto"), 1);
|
|
28421
28534
|
|
|
28422
28535
|
// src/middlewares/openapi/services.ts
|
|
28423
|
-
var
|
|
28424
|
-
var
|
|
28536
|
+
var import_node_fs5 = require("fs");
|
|
28537
|
+
var import_node_path4 = __toESM(require("path"), 1);
|
|
28425
28538
|
var import_typescript = __toESM(require("typescript"), 1);
|
|
28426
28539
|
|
|
28427
28540
|
// src/middlewares/openapi/utils.ts
|
|
28428
|
-
var
|
|
28429
|
-
var
|
|
28541
|
+
var import_node_path3 = __toESM(require("path"), 1);
|
|
28542
|
+
var import_node_fs4 = require("fs");
|
|
28430
28543
|
async function findControllerFiles(dir) {
|
|
28431
28544
|
const files = [];
|
|
28432
28545
|
async function scan(currentDir) {
|
|
28433
|
-
const entries = await
|
|
28546
|
+
const entries = await import_node_fs4.promises.readdir(currentDir, {
|
|
28434
28547
|
withFileTypes: true
|
|
28435
28548
|
});
|
|
28436
28549
|
for (const entry of entries) {
|
|
28437
|
-
const fullPath =
|
|
28550
|
+
const fullPath = import_node_path3.default.join(currentDir, entry.name);
|
|
28438
28551
|
if (entry.isDirectory()) {
|
|
28439
28552
|
await scan(fullPath);
|
|
28440
28553
|
} else if (entry.isFile() && entry.name.endsWith(".controller.ts")) {
|
|
@@ -28507,21 +28620,21 @@ __name(transformOpenapiPaths, "transformOpenapiPaths");
|
|
|
28507
28620
|
// src/middlewares/openapi/services.ts
|
|
28508
28621
|
async function enhanceOpenApiWithSourceInfo(options = {}) {
|
|
28509
28622
|
const startTime = Date.now();
|
|
28510
|
-
const openapiPath = options.openapiPath ||
|
|
28511
|
-
const serverDir = options.serverDir ||
|
|
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");
|
|
28512
28625
|
const writeFile = options.writeFile !== false;
|
|
28513
28626
|
let openapi;
|
|
28514
28627
|
if (options.openapiData) {
|
|
28515
28628
|
openapi = JSON.parse(JSON.stringify(options.openapiData));
|
|
28516
28629
|
} else {
|
|
28517
|
-
const openapiContent = await
|
|
28630
|
+
const openapiContent = await import_node_fs5.promises.readFile(openapiPath, "utf-8");
|
|
28518
28631
|
openapi = JSON.parse(openapiContent);
|
|
28519
28632
|
}
|
|
28520
28633
|
const controllerFiles = await findControllerFiles(serverDir);
|
|
28521
28634
|
const sourceMap = await buildSourceMap(controllerFiles, processControllerFile);
|
|
28522
28635
|
const enhanced = enhanceOpenApiPaths(openapi, sourceMap);
|
|
28523
28636
|
if (writeFile) {
|
|
28524
|
-
await
|
|
28637
|
+
await import_node_fs5.promises.writeFile(openapiPath, JSON.stringify(openapi, null, 2) + "\n", "utf-8");
|
|
28525
28638
|
}
|
|
28526
28639
|
const duration = Date.now() - startTime;
|
|
28527
28640
|
return {
|
|
@@ -28536,8 +28649,8 @@ async function enhanceOpenApiWithSourceInfo(options = {}) {
|
|
|
28536
28649
|
}
|
|
28537
28650
|
__name(enhanceOpenApiWithSourceInfo, "enhanceOpenApiWithSourceInfo");
|
|
28538
28651
|
async function processControllerFile(filePath) {
|
|
28539
|
-
const relativePath =
|
|
28540
|
-
const content = await
|
|
28652
|
+
const relativePath = import_node_path4.default.relative(process.cwd(), filePath);
|
|
28653
|
+
const content = await import_node_fs5.promises.readFile(filePath, "utf-8");
|
|
28541
28654
|
const sourceFile = import_typescript.default.createSourceFile(filePath, content, import_typescript.default.ScriptTarget.Latest, true);
|
|
28542
28655
|
return extractControllerMetadata(sourceFile, relativePath);
|
|
28543
28656
|
}
|
|
@@ -28621,7 +28734,7 @@ function extractControllerMetadata(sourceFile, filePath) {
|
|
|
28621
28734
|
__name(extractControllerMetadata, "extractControllerMetadata");
|
|
28622
28735
|
|
|
28623
28736
|
// src/middlewares/openapi/controller.ts
|
|
28624
|
-
function createOpenapiHandler(openapiFilePath, enableEnhancement) {
|
|
28737
|
+
function createOpenapiHandler(openapiFilePath, enableEnhancement, serverDir) {
|
|
28625
28738
|
let cache = null;
|
|
28626
28739
|
return async (_req, res, context) => {
|
|
28627
28740
|
try {
|
|
@@ -28634,7 +28747,8 @@ function createOpenapiHandler(openapiFilePath, enableEnhancement) {
|
|
|
28634
28747
|
if (enableEnhancement && context.isDev) {
|
|
28635
28748
|
const { openapi: enhancedPayload, stats } = await enhanceOpenApiWithSourceInfo({
|
|
28636
28749
|
openapiData: payload,
|
|
28637
|
-
writeFile: false
|
|
28750
|
+
writeFile: false,
|
|
28751
|
+
serverDir: serverDir || context.rootDir
|
|
28638
28752
|
});
|
|
28639
28753
|
payload = enhancedPayload;
|
|
28640
28754
|
console.log(`[OpenAPI] Enhanced in ${stats.duration}ms (${stats.endpointsEnhanced} endpoints)`);
|
|
@@ -28657,9 +28771,10 @@ function createOpenapiHandler(openapiFilePath, enableEnhancement) {
|
|
|
28657
28771
|
__name(createOpenapiHandler, "createOpenapiHandler");
|
|
28658
28772
|
|
|
28659
28773
|
// src/middlewares/openapi/router.ts
|
|
28660
|
-
function createOpenapiRouter(
|
|
28774
|
+
function createOpenapiRouter(options, context) {
|
|
28775
|
+
const { openapiFilePath, enableEnhancement, serverDir } = options;
|
|
28661
28776
|
const router = import_express.default.Router();
|
|
28662
|
-
const handler = createOpenapiHandler(openapiFilePath, enableEnhancement);
|
|
28777
|
+
const handler = createOpenapiHandler(openapiFilePath, enableEnhancement, serverDir);
|
|
28663
28778
|
router.get("/openapi.json", (req, res) => handler(req, res, context));
|
|
28664
28779
|
return router;
|
|
28665
28780
|
}
|
|
@@ -28674,14 +28789,18 @@ var OPENAPI_ROUTES = [
|
|
|
28674
28789
|
}
|
|
28675
28790
|
];
|
|
28676
28791
|
function createOpenapiMiddleware(options) {
|
|
28677
|
-
const { openapiFilePath, enableEnhancement = true } = options;
|
|
28792
|
+
const { openapiFilePath, enableEnhancement = true, serverDir } = options;
|
|
28678
28793
|
return {
|
|
28679
28794
|
name: "openapi",
|
|
28680
28795
|
mountPath: "/dev",
|
|
28681
28796
|
routes: OPENAPI_ROUTES,
|
|
28682
28797
|
enabled: /* @__PURE__ */ __name((context) => context.isDev, "enabled"),
|
|
28683
28798
|
createRouter: /* @__PURE__ */ __name((context) => {
|
|
28684
|
-
return createOpenapiRouter(
|
|
28799
|
+
return createOpenapiRouter({
|
|
28800
|
+
openapiFilePath,
|
|
28801
|
+
enableEnhancement,
|
|
28802
|
+
serverDir
|
|
28803
|
+
}, context);
|
|
28685
28804
|
}, "createRouter")
|
|
28686
28805
|
};
|
|
28687
28806
|
}
|
|
@@ -28691,8 +28810,8 @@ __name(createOpenapiMiddleware, "createOpenapiMiddleware");
|
|
|
28691
28810
|
var import_express2 = __toESM(require_express2(), 1);
|
|
28692
28811
|
|
|
28693
28812
|
// src/middlewares/dev-logs/utils.ts
|
|
28694
|
-
var
|
|
28695
|
-
var
|
|
28813
|
+
var import_node_fs6 = require("fs");
|
|
28814
|
+
var import_node_path5 = require("path");
|
|
28696
28815
|
|
|
28697
28816
|
// src/middlewares/dev-logs/helper/path-matcher.ts
|
|
28698
28817
|
function pathPatternToRegex(pattern) {
|
|
@@ -28717,40 +28836,40 @@ function matchesPathPattern(actualPath, pattern) {
|
|
|
28717
28836
|
const regex = pathPatternToRegex(normalizedPattern);
|
|
28718
28837
|
return regex.test(normalizedActual);
|
|
28719
28838
|
}
|
|
28720
|
-
return
|
|
28839
|
+
return false;
|
|
28721
28840
|
}
|
|
28722
28841
|
__name(matchesPathPattern, "matchesPathPattern");
|
|
28723
28842
|
function hasSpecialPatterns(pattern) {
|
|
28724
28843
|
return /[{*]/.test(pattern);
|
|
28725
28844
|
}
|
|
28726
28845
|
__name(hasSpecialPatterns, "hasSpecialPatterns");
|
|
28727
|
-
function normalizePathForMatching(
|
|
28728
|
-
return
|
|
28846
|
+
function normalizePathForMatching(path6) {
|
|
28847
|
+
return path6.replace(/\/+/g, "/").replace(/\/+$/, "");
|
|
28729
28848
|
}
|
|
28730
28849
|
__name(normalizePathForMatching, "normalizePathForMatching");
|
|
28731
28850
|
|
|
28732
28851
|
// src/middlewares/dev-logs/utils.ts
|
|
28733
28852
|
function resolveLogDir(provided) {
|
|
28734
28853
|
if (!provided) {
|
|
28735
|
-
return (0,
|
|
28854
|
+
return (0, import_node_path5.join)(process.cwd(), "logs");
|
|
28736
28855
|
}
|
|
28737
|
-
return (0,
|
|
28856
|
+
return (0, import_node_path5.isAbsolute)(provided) ? provided : (0, import_node_path5.join)(process.cwd(), provided);
|
|
28738
28857
|
}
|
|
28739
28858
|
__name(resolveLogDir, "resolveLogDir");
|
|
28740
28859
|
function getRelativePath(filePath) {
|
|
28741
|
-
return (0,
|
|
28860
|
+
return (0, import_node_path5.relative)(process.cwd(), filePath);
|
|
28742
28861
|
}
|
|
28743
28862
|
__name(getRelativePath, "getRelativePath");
|
|
28744
28863
|
async function fileExists(filePath) {
|
|
28745
28864
|
try {
|
|
28746
|
-
await
|
|
28865
|
+
await import_node_fs6.promises.access(filePath);
|
|
28747
28866
|
return true;
|
|
28748
28867
|
} catch {
|
|
28749
28868
|
return false;
|
|
28750
28869
|
}
|
|
28751
28870
|
}
|
|
28752
28871
|
__name(fileExists, "fileExists");
|
|
28753
|
-
function
|
|
28872
|
+
function parseLogLine2(line) {
|
|
28754
28873
|
const trimmed = line.trim();
|
|
28755
28874
|
if (!trimmed) return void 0;
|
|
28756
28875
|
try {
|
|
@@ -28759,7 +28878,7 @@ function parseLogLine(line) {
|
|
|
28759
28878
|
return void 0;
|
|
28760
28879
|
}
|
|
28761
28880
|
}
|
|
28762
|
-
__name(
|
|
28881
|
+
__name(parseLogLine2, "parseLogLine");
|
|
28763
28882
|
function extractNumber(message, pattern) {
|
|
28764
28883
|
if (typeof message !== "string") return void 0;
|
|
28765
28884
|
const match = message.match(pattern);
|
|
@@ -28793,8 +28912,8 @@ function resolveLogFilePath(baseDir, fileName) {
|
|
|
28793
28912
|
if (segments.some((segment) => segment === "..")) {
|
|
28794
28913
|
throw new Error("Invalid log file path");
|
|
28795
28914
|
}
|
|
28796
|
-
const resolved = (0,
|
|
28797
|
-
const rel = (0,
|
|
28915
|
+
const resolved = (0, import_node_path5.join)(baseDir, segments.join("/"));
|
|
28916
|
+
const rel = (0, import_node_path5.relative)(baseDir, resolved);
|
|
28798
28917
|
if (rel.startsWith("..")) {
|
|
28799
28918
|
throw new Error("Access to the specified log file is denied");
|
|
28800
28919
|
}
|
|
@@ -28805,6 +28924,13 @@ function matchesPath(actualPath, pattern) {
|
|
|
28805
28924
|
return matchesPathPattern(actualPath, pattern);
|
|
28806
28925
|
}
|
|
28807
28926
|
__name(matchesPath, "matchesPath");
|
|
28927
|
+
function matchesMethod(actualMethod, expectedMethod) {
|
|
28928
|
+
if (!actualMethod || !expectedMethod) {
|
|
28929
|
+
return false;
|
|
28930
|
+
}
|
|
28931
|
+
return actualMethod.toUpperCase() === expectedMethod.toUpperCase();
|
|
28932
|
+
}
|
|
28933
|
+
__name(matchesMethod, "matchesMethod");
|
|
28808
28934
|
function serializeError(error) {
|
|
28809
28935
|
return error instanceof Error ? {
|
|
28810
28936
|
name: error.name,
|
|
@@ -28816,26 +28942,26 @@ function serializeError(error) {
|
|
|
28816
28942
|
__name(serializeError, "serializeError");
|
|
28817
28943
|
|
|
28818
28944
|
// src/middlewares/dev-logs/controller.ts
|
|
28819
|
-
var
|
|
28945
|
+
var import_node_path6 = require("path");
|
|
28820
28946
|
|
|
28821
28947
|
// src/middlewares/dev-logs/services.ts
|
|
28822
|
-
var
|
|
28823
|
-
var
|
|
28948
|
+
var import_node_fs7 = require("fs");
|
|
28949
|
+
var import_node_readline2 = require("readline");
|
|
28824
28950
|
async function readLogEntriesByTrace(filePath, traceId, limit) {
|
|
28825
28951
|
const exists = await fileExists(filePath);
|
|
28826
28952
|
if (!exists) {
|
|
28827
28953
|
return void 0;
|
|
28828
28954
|
}
|
|
28829
28955
|
const matches = [];
|
|
28830
|
-
const stream = (0,
|
|
28956
|
+
const stream = (0, import_node_fs7.createReadStream)(filePath, {
|
|
28831
28957
|
encoding: "utf8"
|
|
28832
28958
|
});
|
|
28833
|
-
const rl = (0,
|
|
28959
|
+
const rl = (0, import_node_readline2.createInterface)({
|
|
28834
28960
|
input: stream,
|
|
28835
28961
|
crlfDelay: Infinity
|
|
28836
28962
|
});
|
|
28837
28963
|
for await (const line of rl) {
|
|
28838
|
-
const entry =
|
|
28964
|
+
const entry = parseLogLine2(line);
|
|
28839
28965
|
if (!entry) continue;
|
|
28840
28966
|
if (entry.trace_id !== traceId) continue;
|
|
28841
28967
|
matches.push(entry);
|
|
@@ -28848,7 +28974,7 @@ async function readLogEntriesByTrace(filePath, traceId, limit) {
|
|
|
28848
28974
|
return matches;
|
|
28849
28975
|
}
|
|
28850
28976
|
__name(readLogEntriesByTrace, "readLogEntriesByTrace");
|
|
28851
|
-
async function readRecentTraceCalls(filePath, page, pageSize, pathFilter) {
|
|
28977
|
+
async function readRecentTraceCalls(filePath, page, pageSize, pathFilter, methodFilter) {
|
|
28852
28978
|
if (!await fileExists(filePath)) {
|
|
28853
28979
|
return void 0;
|
|
28854
28980
|
}
|
|
@@ -28885,7 +29011,9 @@ async function readRecentTraceCalls(filePath, page, pageSize, pathFilter) {
|
|
|
28885
29011
|
if (!builder.path && entry.path) {
|
|
28886
29012
|
builder.path = String(entry.path);
|
|
28887
29013
|
}
|
|
28888
|
-
const
|
|
29014
|
+
const pathMatches = !pathFilter || matchesPath(builder.path, pathFilter);
|
|
29015
|
+
const methodMatches = !methodFilter || matchesMethod(builder.method, methodFilter);
|
|
29016
|
+
const shouldInclude = pathMatches && methodMatches;
|
|
28889
29017
|
if (shouldInclude) {
|
|
28890
29018
|
completedCalls.push(builder);
|
|
28891
29019
|
}
|
|
@@ -28907,7 +29035,7 @@ async function readRecentTraceCalls(filePath, page, pageSize, pathFilter) {
|
|
|
28907
29035
|
}
|
|
28908
29036
|
}, "processLogEntry");
|
|
28909
29037
|
const processLine = /* @__PURE__ */ __name((line) => {
|
|
28910
|
-
const entry =
|
|
29038
|
+
const entry = parseLogLine2(line);
|
|
28911
29039
|
if (entry?.trace_id) {
|
|
28912
29040
|
processLogEntry(entry);
|
|
28913
29041
|
}
|
|
@@ -28917,7 +29045,7 @@ async function readRecentTraceCalls(filePath, page, pageSize, pathFilter) {
|
|
|
28917
29045
|
}
|
|
28918
29046
|
__name(readRecentTraceCalls, "readRecentTraceCalls");
|
|
28919
29047
|
async function readFileReverse(filePath, chunkSize, processLine) {
|
|
28920
|
-
const handle = await
|
|
29048
|
+
const handle = await import_node_fs7.promises.open(filePath, "r");
|
|
28921
29049
|
try {
|
|
28922
29050
|
const stats = await handle.stat();
|
|
28923
29051
|
let position = stats.size;
|
|
@@ -28979,10 +29107,10 @@ async function readLogFilePage(filePath, page, pageSize) {
|
|
|
28979
29107
|
const capacity = page * pageSize;
|
|
28980
29108
|
const buffer = [];
|
|
28981
29109
|
let totalLines = 0;
|
|
28982
|
-
const stream = (0,
|
|
29110
|
+
const stream = (0, import_node_fs7.createReadStream)(filePath, {
|
|
28983
29111
|
encoding: "utf8"
|
|
28984
29112
|
});
|
|
28985
|
-
const rl = (0,
|
|
29113
|
+
const rl = (0, import_node_readline2.createInterface)({
|
|
28986
29114
|
input: stream,
|
|
28987
29115
|
crlfDelay: Infinity
|
|
28988
29116
|
});
|
|
@@ -29043,7 +29171,7 @@ function handleError(res, error, message = "Failed to read log file") {
|
|
|
29043
29171
|
}
|
|
29044
29172
|
__name(handleError, "handleError");
|
|
29045
29173
|
function createGetTraceEntriesHandler(logDir) {
|
|
29046
|
-
const appLogPath = (0,
|
|
29174
|
+
const appLogPath = (0, import_node_path6.join)(logDir, "app.log");
|
|
29047
29175
|
return async (req, res) => {
|
|
29048
29176
|
const traceId = (req.params.traceId || "").trim();
|
|
29049
29177
|
if (!traceId) {
|
|
@@ -29070,13 +29198,14 @@ function createGetTraceEntriesHandler(logDir) {
|
|
|
29070
29198
|
}
|
|
29071
29199
|
__name(createGetTraceEntriesHandler, "createGetTraceEntriesHandler");
|
|
29072
29200
|
function createGetRecentTracesHandler(logDir) {
|
|
29073
|
-
const traceLogPath = (0,
|
|
29201
|
+
const traceLogPath = (0, import_node_path6.join)(logDir, "trace.log");
|
|
29074
29202
|
return async (req, res) => {
|
|
29075
29203
|
const page = parsePositiveInt(req.query.page, 1);
|
|
29076
29204
|
const pageSize = parseLimit(req.query.pageSize, 10, 100);
|
|
29077
29205
|
const pathFilter = typeof req.query.path === "string" ? req.query.path.trim() : void 0;
|
|
29206
|
+
const methodFilter = typeof req.query.method === "string" ? req.query.method.trim().toUpperCase() : void 0;
|
|
29078
29207
|
try {
|
|
29079
|
-
const result = await readRecentTraceCalls(traceLogPath, page, pageSize, pathFilter);
|
|
29208
|
+
const result = await readRecentTraceCalls(traceLogPath, page, pageSize, pathFilter, methodFilter);
|
|
29080
29209
|
if (!result) {
|
|
29081
29210
|
return handleNotFound(res, traceLogPath);
|
|
29082
29211
|
}
|
|
@@ -29084,6 +29213,7 @@ function createGetRecentTracesHandler(logDir) {
|
|
|
29084
29213
|
file: getRelativePath(traceLogPath),
|
|
29085
29214
|
...result,
|
|
29086
29215
|
path: pathFilter || null,
|
|
29216
|
+
method: methodFilter || null,
|
|
29087
29217
|
count: result.calls.length
|
|
29088
29218
|
});
|
|
29089
29219
|
} catch (error) {
|
|
@@ -29140,7 +29270,7 @@ var DEV_LOGS_ROUTES = [
|
|
|
29140
29270
|
{
|
|
29141
29271
|
method: "GET",
|
|
29142
29272
|
path: "/trace/recent",
|
|
29143
|
-
description: "Get recent trace calls with pagination and optional path
|
|
29273
|
+
description: "Get recent trace calls with pagination and optional path/method filters"
|
|
29144
29274
|
},
|
|
29145
29275
|
{
|
|
29146
29276
|
method: "GET",
|
|
@@ -29164,6 +29294,138 @@ function createDevLogsMiddleware(options = {}) {
|
|
|
29164
29294
|
}
|
|
29165
29295
|
__name(createDevLogsMiddleware, "createDevLogsMiddleware");
|
|
29166
29296
|
|
|
29297
|
+
// src/middlewares/collect-logs/router.ts
|
|
29298
|
+
var import_express3 = __toESM(require_express2(), 1);
|
|
29299
|
+
|
|
29300
|
+
// src/middlewares/collect-logs/controller.ts
|
|
29301
|
+
var import_path = require("path");
|
|
29302
|
+
var import_fs = __toESM(require("fs"), 1);
|
|
29303
|
+
|
|
29304
|
+
// src/middlewares/collect-logs/utils.ts
|
|
29305
|
+
var import_node_path7 = require("path");
|
|
29306
|
+
var import_node_fs8 = __toESM(require("fs"), 1);
|
|
29307
|
+
function resolveLogDir2(provided) {
|
|
29308
|
+
if (!provided) {
|
|
29309
|
+
return (0, import_node_path7.join)(process.cwd(), "logs");
|
|
29310
|
+
}
|
|
29311
|
+
return (0, import_node_path7.isAbsolute)(provided) ? provided : (0, import_node_path7.join)(process.cwd(), provided);
|
|
29312
|
+
}
|
|
29313
|
+
__name(resolveLogDir2, "resolveLogDir");
|
|
29314
|
+
function ensureDir(dir) {
|
|
29315
|
+
if (!import_node_fs8.default.existsSync(dir)) {
|
|
29316
|
+
import_node_fs8.default.mkdirSync(dir, {
|
|
29317
|
+
recursive: true
|
|
29318
|
+
});
|
|
29319
|
+
}
|
|
29320
|
+
}
|
|
29321
|
+
__name(ensureDir, "ensureDir");
|
|
29322
|
+
function serializeError2(error) {
|
|
29323
|
+
return error instanceof Error ? {
|
|
29324
|
+
name: error.name,
|
|
29325
|
+
message: error.message
|
|
29326
|
+
} : {
|
|
29327
|
+
message: String(error)
|
|
29328
|
+
};
|
|
29329
|
+
}
|
|
29330
|
+
__name(serializeError2, "serializeError");
|
|
29331
|
+
|
|
29332
|
+
// src/middlewares/collect-logs/controller.ts
|
|
29333
|
+
function collectLogsHandler(logDir, fileName) {
|
|
29334
|
+
const filePath = (0, import_path.join)(logDir, fileName);
|
|
29335
|
+
ensureDir(logDir);
|
|
29336
|
+
return async (req, res) => {
|
|
29337
|
+
try {
|
|
29338
|
+
const logContent = req.body;
|
|
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";
|
|
29348
|
+
await import_fs.default.promises.appendFile(filePath, logLine);
|
|
29349
|
+
res.json({
|
|
29350
|
+
success: true
|
|
29351
|
+
});
|
|
29352
|
+
} catch (error) {
|
|
29353
|
+
handleError2(res, error, "Failed to collect logs");
|
|
29354
|
+
}
|
|
29355
|
+
};
|
|
29356
|
+
}
|
|
29357
|
+
__name(collectLogsHandler, "collectLogsHandler");
|
|
29358
|
+
function collectLogsBatchHandler(logDir, fileName) {
|
|
29359
|
+
const filePath = (0, import_path.join)(logDir, fileName);
|
|
29360
|
+
ensureDir(logDir);
|
|
29361
|
+
return async (req, res) => {
|
|
29362
|
+
try {
|
|
29363
|
+
const logContents = req.body;
|
|
29364
|
+
if (!Array.isArray(logContents)) {
|
|
29365
|
+
return res.status(400).json({
|
|
29366
|
+
message: "logContents must be an array"
|
|
29367
|
+
});
|
|
29368
|
+
}
|
|
29369
|
+
const logLines = [];
|
|
29370
|
+
for (const logContent of logContents) {
|
|
29371
|
+
logLines.push(JSON.stringify({
|
|
29372
|
+
...logContent,
|
|
29373
|
+
server_time: (/* @__PURE__ */ new Date()).toISOString()
|
|
29374
|
+
}) + "\n");
|
|
29375
|
+
}
|
|
29376
|
+
await import_fs.default.promises.appendFile(filePath, logLines.join(""));
|
|
29377
|
+
res.json({
|
|
29378
|
+
success: true
|
|
29379
|
+
});
|
|
29380
|
+
} catch (error) {
|
|
29381
|
+
handleError2(res, error, "Failed to collect logs");
|
|
29382
|
+
}
|
|
29383
|
+
};
|
|
29384
|
+
}
|
|
29385
|
+
__name(collectLogsBatchHandler, "collectLogsBatchHandler");
|
|
29386
|
+
function handleError2(res, error, message = "Failed to collect logs") {
|
|
29387
|
+
res.status(500).json({
|
|
29388
|
+
message,
|
|
29389
|
+
error: serializeError2(error)
|
|
29390
|
+
});
|
|
29391
|
+
}
|
|
29392
|
+
__name(handleError2, "handleError");
|
|
29393
|
+
|
|
29394
|
+
// src/middlewares/collect-logs/router.ts
|
|
29395
|
+
function createDevLogRouter2(options = {}) {
|
|
29396
|
+
const logDir = resolveLogDir2(options.logDir);
|
|
29397
|
+
const router = import_express3.default.Router();
|
|
29398
|
+
router.post("/collect", import_express3.default.json(), collectLogsHandler(logDir, options.fileName || "client.log"));
|
|
29399
|
+
router.post("/collect-batch", import_express3.default.json(), collectLogsBatchHandler(logDir, options.fileName || "client.log"));
|
|
29400
|
+
return router;
|
|
29401
|
+
}
|
|
29402
|
+
__name(createDevLogRouter2, "createDevLogRouter");
|
|
29403
|
+
|
|
29404
|
+
// src/middlewares/collect-logs/index.ts
|
|
29405
|
+
var DEV_LOGS_ROUTES2 = [
|
|
29406
|
+
{
|
|
29407
|
+
method: "POST",
|
|
29408
|
+
path: "/collect",
|
|
29409
|
+
description: "Collect logs from client."
|
|
29410
|
+
}
|
|
29411
|
+
];
|
|
29412
|
+
function createCollectLogsMiddleware(options = {}) {
|
|
29413
|
+
const { logDir } = options;
|
|
29414
|
+
return {
|
|
29415
|
+
name: "collect-logs",
|
|
29416
|
+
mountPath: "/dev/logs",
|
|
29417
|
+
routes: DEV_LOGS_ROUTES2,
|
|
29418
|
+
enabled: /* @__PURE__ */ __name((context) => context.isDev, "enabled"),
|
|
29419
|
+
createRouter: /* @__PURE__ */ __name((context) => {
|
|
29420
|
+
return createDevLogRouter2({
|
|
29421
|
+
logDir: logDir || context.logDir,
|
|
29422
|
+
fileName: options.fileName || "client.log"
|
|
29423
|
+
});
|
|
29424
|
+
}, "createRouter")
|
|
29425
|
+
};
|
|
29426
|
+
}
|
|
29427
|
+
__name(createCollectLogsMiddleware, "createCollectLogsMiddleware");
|
|
29428
|
+
|
|
29167
29429
|
// src/middlewares/index.ts
|
|
29168
29430
|
function isRouteMiddleware(middleware) {
|
|
29169
29431
|
return "createRouter" in middleware && middleware.createRouter !== void 0;
|
|
@@ -29174,7 +29436,7 @@ function isGlobalMiddleware(middleware) {
|
|
|
29174
29436
|
}
|
|
29175
29437
|
__name(isGlobalMiddleware, "isGlobalMiddleware");
|
|
29176
29438
|
function computeMountPath(basePath, mountPath) {
|
|
29177
|
-
const routePath =
|
|
29439
|
+
const routePath = import_node_path8.default.posix.join(basePath, mountPath);
|
|
29178
29440
|
return routePath.startsWith("/") ? routePath : `/${routePath}`;
|
|
29179
29441
|
}
|
|
29180
29442
|
__name(computeMountPath, "computeMountPath");
|
|
@@ -29182,7 +29444,7 @@ function logMiddlewareRegistration(middleware, fullMountPath) {
|
|
|
29182
29444
|
if (middleware.routes && middleware.routes.length > 0) {
|
|
29183
29445
|
console.log(`[Middleware] Registered: ${middleware.name} at ${fullMountPath}`);
|
|
29184
29446
|
middleware.routes.forEach((route) => {
|
|
29185
|
-
const routePath = route.path === "/" ? fullMountPath :
|
|
29447
|
+
const routePath = route.path === "/" ? fullMountPath : import_node_path8.default.posix.join(fullMountPath, route.path);
|
|
29186
29448
|
console.log(` ${route.method} ${routePath} - ${route.description}`);
|
|
29187
29449
|
});
|
|
29188
29450
|
} else {
|
|
@@ -29242,8 +29504,10 @@ async function registerMiddlewares(server, middlewares, options) {
|
|
|
29242
29504
|
__name(registerMiddlewares, "registerMiddlewares");
|
|
29243
29505
|
// Annotate the CommonJS export names for ESM import in node:
|
|
29244
29506
|
0 && (module.exports = {
|
|
29507
|
+
createCollectLogsMiddleware,
|
|
29245
29508
|
createDevLogsMiddleware,
|
|
29246
29509
|
createOpenapiMiddleware,
|
|
29510
|
+
handleDevProxyError,
|
|
29247
29511
|
normalizeBasePath,
|
|
29248
29512
|
postprocessDrizzleSchema,
|
|
29249
29513
|
registerMiddlewares
|