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.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './context';
2
2
  export * from './middleware';
3
+ export * from './router';
3
4
  export * from './shokupan';
4
5
  export * from './util/decorators';
5
6
  export * from './util/di';
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { nanoid } from "nanoid";
2
2
  import { readFile } from "node:fs/promises";
3
3
  import { inspect } from "node:util";
4
- import { trace, SpanKind, SpanStatusCode, context } from "@opentelemetry/api";
5
- import { dump } from "js-yaml";
6
- import { AsyncLocalStorage } from "node:async_hooks";
7
4
  import { RecordId, Surreal } from "surrealdb";
8
5
  import { Eta } from "eta";
9
6
  import { stat, readdir, readFile as readFile$1 } from "fs/promises";
10
7
  import { resolve, join, sep, basename } from "path";
8
+ import { trace, SpanKind, SpanStatusCode, context } from "@opentelemetry/api";
9
+ import { dump } from "js-yaml";
10
+ import { AsyncLocalStorage } from "node:async_hooks";
11
11
  import * as os from "node:os";
12
12
  import os__default from "node:os";
13
13
  import { dirname, join as join$1 } from "node:path";
@@ -1317,40 +1317,6 @@ async function generateOpenApi(rootRouter, options = {}) {
1317
1317
  "x-tagGroups": xTagGroups
1318
1318
  };
1319
1319
  }
1320
- class RequestContextStore {
1321
- request;
1322
- span;
1323
- }
1324
- const asyncContext = new AsyncLocalStorage();
1325
- class HttpError extends Error {
1326
- status;
1327
- constructor(message, status) {
1328
- super(message);
1329
- this.name = "HttpError";
1330
- this.status = status;
1331
- if (Error.captureStackTrace) {
1332
- Error.captureStackTrace(this, HttpError);
1333
- }
1334
- }
1335
- }
1336
- function getErrorStatus(err) {
1337
- if (!err || typeof err !== "object") {
1338
- return 500;
1339
- }
1340
- if (typeof err.status === "number") {
1341
- return err.status;
1342
- }
1343
- if (typeof err.statusCode === "number") {
1344
- return err.statusCode;
1345
- }
1346
- return 500;
1347
- }
1348
- class EventError extends HttpError {
1349
- constructor(message = "Event Error") {
1350
- super(message, 500);
1351
- this.name = "EventError";
1352
- }
1353
- }
1354
1320
  const eta = new Eta();
1355
1321
  function serveStatic(config, prefix) {
1356
1322
  const rootPath = resolve(config.root || ".");
@@ -1536,6 +1502,35 @@ function Inject(token) {
1536
1502
  });
1537
1503
  };
1538
1504
  }
1505
+ class HttpError extends Error {
1506
+ status;
1507
+ constructor(message, status) {
1508
+ super(message);
1509
+ this.name = "HttpError";
1510
+ this.status = status;
1511
+ if (Error.captureStackTrace) {
1512
+ Error.captureStackTrace(this, HttpError);
1513
+ }
1514
+ }
1515
+ }
1516
+ function getErrorStatus(err) {
1517
+ if (!err || typeof err !== "object") {
1518
+ return 500;
1519
+ }
1520
+ if (typeof err.status === "number") {
1521
+ return err.status;
1522
+ }
1523
+ if (typeof err.statusCode === "number") {
1524
+ return err.statusCode;
1525
+ }
1526
+ return 500;
1527
+ }
1528
+ class EventError extends HttpError {
1529
+ constructor(message = "Event Error") {
1530
+ super(message, 500);
1531
+ this.name = "EventError";
1532
+ }
1533
+ }
1539
1534
  const tracer = trace.getTracer("shokupan.middleware");
1540
1535
  function traceHandler(fn, name) {
1541
1536
  return async function(...args) {
@@ -1725,6 +1720,8 @@ var RouteParamType = /* @__PURE__ */ ((RouteParamType2) => {
1725
1720
  RouteParamType2["CONTEXT"] = "CONTEXT";
1726
1721
  return RouteParamType2;
1727
1722
  })(RouteParamType || {});
1723
+ const RouterRegistry = /* @__PURE__ */ new Map();
1724
+ const ShokupanApplicationTree = {};
1728
1725
  class ShokupanRouter {
1729
1726
  constructor(config) {
1730
1727
  this.config = config;
@@ -2719,6 +2716,11 @@ class ShokupanRouter {
2719
2716
  }
2720
2717
  }
2721
2718
  }
2719
+ class RequestContextStore {
2720
+ request;
2721
+ span;
2722
+ }
2723
+ const asyncContext = new AsyncLocalStorage();
2722
2724
  class SystemCpuMonitor {
2723
2725
  constructor(intervalMs = 1e3) {
2724
2726
  this.intervalMs = intervalMs;
@@ -6394,13 +6396,16 @@ export {
6394
6396
  RateLimitMiddleware,
6395
6397
  Req,
6396
6398
  RouteParamType,
6399
+ RouterRegistry,
6397
6400
  ScalarPlugin,
6398
6401
  SecurityHeaders,
6399
6402
  Session,
6400
6403
  Shokupan,
6404
+ ShokupanApplicationTree,
6401
6405
  ShokupanContext,
6402
6406
  ShokupanRequest,
6403
6407
  ShokupanResponse,
6408
+ ShokupanRouter,
6404
6409
  Spec,
6405
6410
  Use,
6406
6411
  ValidationError,