shokupan 0.10.0 → 0.10.1
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 +42 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +42 -37
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -25,13 +25,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
25
25
|
const nanoid = require("nanoid");
|
|
26
26
|
const promises = require("node:fs/promises");
|
|
27
27
|
const node_util = require("node:util");
|
|
28
|
-
const api = require("@opentelemetry/api");
|
|
29
|
-
const jsYaml = require("js-yaml");
|
|
30
|
-
const node_async_hooks = require("node:async_hooks");
|
|
31
28
|
const surrealdb = require("surrealdb");
|
|
32
29
|
const eta$1 = require("eta");
|
|
33
30
|
const promises$1 = require("fs/promises");
|
|
34
31
|
const path = require("path");
|
|
32
|
+
const api = require("@opentelemetry/api");
|
|
33
|
+
const jsYaml = require("js-yaml");
|
|
34
|
+
const node_async_hooks = require("node:async_hooks");
|
|
35
35
|
const os = require("node:os");
|
|
36
36
|
const path$1 = require("node:path");
|
|
37
37
|
const node_url = require("node:url");
|
|
@@ -1359,40 +1359,6 @@ async function generateOpenApi(rootRouter, options = {}) {
|
|
|
1359
1359
|
"x-tagGroups": xTagGroups
|
|
1360
1360
|
};
|
|
1361
1361
|
}
|
|
1362
|
-
class RequestContextStore {
|
|
1363
|
-
request;
|
|
1364
|
-
span;
|
|
1365
|
-
}
|
|
1366
|
-
const asyncContext = new node_async_hooks.AsyncLocalStorage();
|
|
1367
|
-
class HttpError extends Error {
|
|
1368
|
-
status;
|
|
1369
|
-
constructor(message, status) {
|
|
1370
|
-
super(message);
|
|
1371
|
-
this.name = "HttpError";
|
|
1372
|
-
this.status = status;
|
|
1373
|
-
if (Error.captureStackTrace) {
|
|
1374
|
-
Error.captureStackTrace(this, HttpError);
|
|
1375
|
-
}
|
|
1376
|
-
}
|
|
1377
|
-
}
|
|
1378
|
-
function getErrorStatus(err) {
|
|
1379
|
-
if (!err || typeof err !== "object") {
|
|
1380
|
-
return 500;
|
|
1381
|
-
}
|
|
1382
|
-
if (typeof err.status === "number") {
|
|
1383
|
-
return err.status;
|
|
1384
|
-
}
|
|
1385
|
-
if (typeof err.statusCode === "number") {
|
|
1386
|
-
return err.statusCode;
|
|
1387
|
-
}
|
|
1388
|
-
return 500;
|
|
1389
|
-
}
|
|
1390
|
-
class EventError extends HttpError {
|
|
1391
|
-
constructor(message = "Event Error") {
|
|
1392
|
-
super(message, 500);
|
|
1393
|
-
this.name = "EventError";
|
|
1394
|
-
}
|
|
1395
|
-
}
|
|
1396
1362
|
const eta = new eta$1.Eta();
|
|
1397
1363
|
function serveStatic(config, prefix) {
|
|
1398
1364
|
const rootPath = path.resolve(config.root || ".");
|
|
@@ -1578,6 +1544,35 @@ function Inject(token) {
|
|
|
1578
1544
|
});
|
|
1579
1545
|
};
|
|
1580
1546
|
}
|
|
1547
|
+
class HttpError extends Error {
|
|
1548
|
+
status;
|
|
1549
|
+
constructor(message, status) {
|
|
1550
|
+
super(message);
|
|
1551
|
+
this.name = "HttpError";
|
|
1552
|
+
this.status = status;
|
|
1553
|
+
if (Error.captureStackTrace) {
|
|
1554
|
+
Error.captureStackTrace(this, HttpError);
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
function getErrorStatus(err) {
|
|
1559
|
+
if (!err || typeof err !== "object") {
|
|
1560
|
+
return 500;
|
|
1561
|
+
}
|
|
1562
|
+
if (typeof err.status === "number") {
|
|
1563
|
+
return err.status;
|
|
1564
|
+
}
|
|
1565
|
+
if (typeof err.statusCode === "number") {
|
|
1566
|
+
return err.statusCode;
|
|
1567
|
+
}
|
|
1568
|
+
return 500;
|
|
1569
|
+
}
|
|
1570
|
+
class EventError extends HttpError {
|
|
1571
|
+
constructor(message = "Event Error") {
|
|
1572
|
+
super(message, 500);
|
|
1573
|
+
this.name = "EventError";
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1581
1576
|
const tracer = api.trace.getTracer("shokupan.middleware");
|
|
1582
1577
|
function traceHandler(fn, name) {
|
|
1583
1578
|
return async function(...args) {
|
|
@@ -1767,6 +1762,8 @@ var RouteParamType = /* @__PURE__ */ ((RouteParamType2) => {
|
|
|
1767
1762
|
RouteParamType2["CONTEXT"] = "CONTEXT";
|
|
1768
1763
|
return RouteParamType2;
|
|
1769
1764
|
})(RouteParamType || {});
|
|
1765
|
+
const RouterRegistry = /* @__PURE__ */ new Map();
|
|
1766
|
+
const ShokupanApplicationTree = {};
|
|
1770
1767
|
class ShokupanRouter {
|
|
1771
1768
|
constructor(config) {
|
|
1772
1769
|
this.config = config;
|
|
@@ -2761,6 +2758,11 @@ class ShokupanRouter {
|
|
|
2761
2758
|
}
|
|
2762
2759
|
}
|
|
2763
2760
|
}
|
|
2761
|
+
class RequestContextStore {
|
|
2762
|
+
request;
|
|
2763
|
+
span;
|
|
2764
|
+
}
|
|
2765
|
+
const asyncContext = new node_async_hooks.AsyncLocalStorage();
|
|
2764
2766
|
class SystemCpuMonitor {
|
|
2765
2767
|
constructor(intervalMs = 1e3) {
|
|
2766
2768
|
this.intervalMs = intervalMs;
|
|
@@ -6435,13 +6437,16 @@ exports.RateLimit = RateLimit;
|
|
|
6435
6437
|
exports.RateLimitMiddleware = RateLimitMiddleware;
|
|
6436
6438
|
exports.Req = Req;
|
|
6437
6439
|
exports.RouteParamType = RouteParamType;
|
|
6440
|
+
exports.RouterRegistry = RouterRegistry;
|
|
6438
6441
|
exports.ScalarPlugin = ScalarPlugin;
|
|
6439
6442
|
exports.SecurityHeaders = SecurityHeaders;
|
|
6440
6443
|
exports.Session = Session;
|
|
6441
6444
|
exports.Shokupan = Shokupan;
|
|
6445
|
+
exports.ShokupanApplicationTree = ShokupanApplicationTree;
|
|
6442
6446
|
exports.ShokupanContext = ShokupanContext;
|
|
6443
6447
|
exports.ShokupanRequest = ShokupanRequest;
|
|
6444
6448
|
exports.ShokupanResponse = ShokupanResponse;
|
|
6449
|
+
exports.ShokupanRouter = ShokupanRouter;
|
|
6445
6450
|
exports.Spec = Spec;
|
|
6446
6451
|
exports.Use = Use;
|
|
6447
6452
|
exports.ValidationError = ValidationError;
|