@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.
@@ -13,3 +13,4 @@ declare const createCert: (attrs?: Attributes[], altNames?: AltNames[]) => {
13
13
  };
14
14
 
15
15
  export { createCert };
16
+ export type { AltNames, Attributes };
@@ -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: 'Hangzhou' }, // 城市名
28625
- { name: 'organizationName', value: 'Envision' }, // 组织名
28626
- { name: 'organizationalUnitName', value: 'IT' }, // 组织单位
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.filter((item, index, self) => {
28631
- return self.findIndex((t) => t.name === item.name) === index;
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
- setContext(ctx: RouteContext): Promise<void>;
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$1, res: ServerResponse$1): Promise<{
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, Connect, CustomError, QueryConnect, QueryRouter, QueryRouterServer, QueryUtil, Route, Server, createSchema, define, handleServer, util };
699
+ export { App, CustomError, QueryRouter, QueryRouterServer, QueryUtil, Route, Server, createSchema, define, handleServer, util };
725
700
  export type { RouteArray, RouteContext, RouteMiddleware, RouteObject, RouteOpts, Rule, Run };