@kevisual/router 0.0.22 → 0.0.23

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
@@ -109,7 +109,7 @@ type RouteContext<T = {
109
109
  }) => Promise<any>;
110
110
  index?: number;
111
111
  throw?: (code?: number | string, message?: string, tips?: string) => void;
112
- /** 是否需要序列化 */
112
+ /** 是否需要序列化, 使用JSON.stringify和JSON.parse */
113
113
  needSerialize?: boolean;
114
114
  } & T;
115
115
  type SimpleObject$1 = Record<string, any>;
@@ -326,7 +326,12 @@ declare class QueryRouter {
326
326
  data: any;
327
327
  message: any;
328
328
  }>;
329
- setContext(ctx: RouteContext): Promise<void>;
329
+ /**
330
+ * 设置上下文
331
+ * @description 这里的上下文是为了在handle函数中使用
332
+ * @param ctx
333
+ */
334
+ setContext(ctx: RouteContext): void;
330
335
  getList(): RouteInfo[];
331
336
  /**
332
337
  * 获取handle函数, 这里会去执行parse函数
@@ -719,6 +724,7 @@ declare class App<T = {}, U = AppReqRes> {
719
724
  cookies: Record<string, string>;
720
725
  token: string;
721
726
  }>;
727
+ onServerRequest(fn: (req: IncomingMessage$1, res: ServerResponse$1) => void): void;
722
728
  }
723
729
 
724
730
  export { App, Connect, CustomError, QueryConnect, QueryRouter, QueryRouterServer, QueryUtil, Route, Server, createSchema, define, handleServer, util };