@kevisual/router 0.0.22 → 0.0.24
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/router-browser.d.ts +10 -3
- package/dist/router-browser.js +17439 -530
- package/dist/router-sign.d.ts +1 -0
- package/dist/router-sign.js +15 -7
- package/dist/router.d.ts +10 -35
- package/dist/router.js +17446 -597
- package/package.json +22 -9
- package/readme.md +14 -0
- package/src/app-browser.ts +5 -0
- package/src/app.ts +7 -1
- package/src/auto/call-sock.ts +151 -0
- package/src/auto/listen/cleanup.ts +102 -0
- package/src/auto/listen/run-check.ts +50 -0
- package/src/auto/listen-sock.ts +245 -0
- package/src/auto/load-ts.ts +37 -0
- package/src/auto/runtime.ts +19 -0
- package/src/auto/utils/glob.ts +83 -0
- package/src/browser.ts +3 -1
- package/src/index.ts +3 -3
- package/src/route.ts +8 -3
- package/src/sign.ts +22 -9
- package/src/test/static.ts +22 -0
- package/src/utils/is-engine.ts +15 -0
- package/src/validator/index.ts +3 -1
- package/src/connect.ts +0 -67
package/dist/router-sign.d.ts
CHANGED
package/dist/router-sign.js
CHANGED
|
@@ -28618,18 +28618,18 @@ var selfsignedExports = requireSelfsigned();
|
|
|
28618
28618
|
|
|
28619
28619
|
const createCert = (attrs = [], altNames = []) => {
|
|
28620
28620
|
let attributes = [
|
|
28621
|
-
{ name: 'commonName', value: '*' }, // 通配符域名
|
|
28622
28621
|
{ name: 'countryName', value: 'CN' }, // 国家代码
|
|
28623
28622
|
{ name: 'stateOrProvinceName', value: 'ZheJiang' }, // 州名
|
|
28624
|
-
{ name: 'localityName', value: '
|
|
28625
|
-
{ name: 'organizationName', value: '
|
|
28626
|
-
{ name: 'organizationalUnitName', value: '
|
|
28623
|
+
{ name: 'localityName', value: 'HangZhou' }, // 城市名
|
|
28624
|
+
{ name: 'organizationName', value: 'kevisual' }, // 组织名
|
|
28625
|
+
{ name: 'organizationalUnitName', value: 'kevisual' }, // 组织单位
|
|
28627
28626
|
...attrs,
|
|
28628
28627
|
];
|
|
28629
28628
|
// attribute 根据name去重复, 后面的覆盖前面的
|
|
28630
|
-
attributes = attributes.
|
|
28631
|
-
|
|
28632
|
-
|
|
28629
|
+
attributes = Object.values(attributes.reduce((acc, attr) => ({
|
|
28630
|
+
...acc,
|
|
28631
|
+
[attr.name]: attr,
|
|
28632
|
+
}), {}));
|
|
28633
28633
|
const options = {
|
|
28634
28634
|
days: 365, // 证书有效期(天)
|
|
28635
28635
|
extensions: [
|
|
@@ -28638,6 +28638,14 @@ const createCert = (attrs = [], altNames = []) => {
|
|
|
28638
28638
|
altNames: [
|
|
28639
28639
|
{ type: 2, value: '*' }, // DNS 名称
|
|
28640
28640
|
{ type: 2, value: 'localhost' }, // DNS
|
|
28641
|
+
{
|
|
28642
|
+
type: 2,
|
|
28643
|
+
value: '[::1]',
|
|
28644
|
+
},
|
|
28645
|
+
{
|
|
28646
|
+
type: 7,
|
|
28647
|
+
ip: 'fe80::1',
|
|
28648
|
+
},
|
|
28641
28649
|
{ type: 7, ip: '127.0.0.1' }, // IP 地址
|
|
28642
28650
|
...altNames,
|
|
28643
28651
|
],
|
package/dist/router.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ import https from 'node:https';
|
|
|
5
5
|
import http2 from 'node:http2';
|
|
6
6
|
import * as cookie from 'cookie';
|
|
7
7
|
import { WebSocketServer, WebSocket } from 'ws';
|
|
8
|
-
import { IncomingMessage as IncomingMessage$1, ServerResponse as ServerResponse$1 } from 'http';
|
|
9
8
|
import { RouteOpts as RouteOpts$1, QueryRouterServer as QueryRouterServer$1, RouteMiddleware as RouteMiddleware$1, Run as Run$1 } from '@kevisual/router';
|
|
10
9
|
import { Query, DataOpts, Result } from '@kevisual/query/query';
|
|
11
10
|
|
|
@@ -109,7 +108,7 @@ type RouteContext<T = {
|
|
|
109
108
|
}) => Promise<any>;
|
|
110
109
|
index?: number;
|
|
111
110
|
throw?: (code?: number | string, message?: string, tips?: string) => void;
|
|
112
|
-
/**
|
|
111
|
+
/** 是否需要序列化, 使用JSON.stringify和JSON.parse */
|
|
113
112
|
needSerialize?: boolean;
|
|
114
113
|
} & T;
|
|
115
114
|
type SimpleObject$1 = Record<string, any>;
|
|
@@ -326,7 +325,12 @@ declare class QueryRouter {
|
|
|
326
325
|
data: any;
|
|
327
326
|
message: any;
|
|
328
327
|
}>;
|
|
329
|
-
|
|
328
|
+
/**
|
|
329
|
+
* 设置上下文
|
|
330
|
+
* @description 这里的上下文是为了在handle函数中使用
|
|
331
|
+
* @param ctx
|
|
332
|
+
*/
|
|
333
|
+
setContext(ctx: RouteContext): void;
|
|
330
334
|
getList(): RouteInfo[];
|
|
331
335
|
/**
|
|
332
336
|
* 获取handle函数, 这里会去执行parse函数
|
|
@@ -402,36 +406,6 @@ declare class QueryRouterServer extends QueryRouter {
|
|
|
402
406
|
}): Promise<any>;
|
|
403
407
|
}
|
|
404
408
|
|
|
405
|
-
declare class Connect {
|
|
406
|
-
path: string;
|
|
407
|
-
key?: string;
|
|
408
|
-
_fn?: (ctx?: RouteContext) => Promise<RouteContext>;
|
|
409
|
-
description?: string;
|
|
410
|
-
connects: {
|
|
411
|
-
path: string;
|
|
412
|
-
key?: string;
|
|
413
|
-
}[];
|
|
414
|
-
share: boolean;
|
|
415
|
-
constructor(path: string);
|
|
416
|
-
use(path: string): void;
|
|
417
|
-
useList(paths: string[]): void;
|
|
418
|
-
useConnect(connect: Connect): void;
|
|
419
|
-
useConnectList(connects: Connect[]): void;
|
|
420
|
-
getPathList(): string[];
|
|
421
|
-
set fn(fn: (ctx?: RouteContext) => Promise<RouteContext>);
|
|
422
|
-
get fn(): (ctx?: RouteContext) => Promise<RouteContext>;
|
|
423
|
-
}
|
|
424
|
-
declare class QueryConnect {
|
|
425
|
-
connects: Connect[];
|
|
426
|
-
constructor();
|
|
427
|
-
add(connect: Connect): void;
|
|
428
|
-
remove(connect: Connect): void;
|
|
429
|
-
getList(): {
|
|
430
|
-
path: string;
|
|
431
|
-
key: string;
|
|
432
|
-
}[];
|
|
433
|
-
}
|
|
434
|
-
|
|
435
409
|
type Listener = (...args: any[]) => void;
|
|
436
410
|
type CookieFn = (name: string, value: string, options?: cookie.SerializeOptions, end?: boolean) => void;
|
|
437
411
|
type HandleCtx = {
|
|
@@ -715,11 +689,12 @@ declare class App<T = {}, U = AppReqRes> {
|
|
|
715
689
|
importRoutes(routes: any[]): void;
|
|
716
690
|
importApp(app: App): void;
|
|
717
691
|
throw(code?: number | string, message?: string, tips?: string): void;
|
|
718
|
-
static handleRequest(req: IncomingMessage
|
|
692
|
+
static handleRequest(req: IncomingMessage, res: ServerResponse): Promise<{
|
|
719
693
|
cookies: Record<string, string>;
|
|
720
694
|
token: string;
|
|
721
695
|
}>;
|
|
696
|
+
onServerRequest(fn: (req: IncomingMessage, res: ServerResponse) => void): void;
|
|
722
697
|
}
|
|
723
698
|
|
|
724
|
-
export { App,
|
|
699
|
+
export { App, CustomError, QueryRouter, QueryRouterServer, QueryUtil, Route, Server, createSchema, define, handleServer, util };
|
|
725
700
|
export type { RouteArray, RouteContext, RouteMiddleware, RouteObject, RouteOpts, Rule, Run };
|