更新依赖项,添加 Connect 和 QueryConnect 类,重构导出结构

This commit is contained in:
xiongxiao
2026-01-15 21:21:35 +08:00
parent 2c57435a81
commit 309446c864
7 changed files with 70 additions and 255 deletions

View File

@@ -6,10 +6,10 @@ export { createSchema } from './validator/index.ts';
export type { RouteContext, RouteOpts } from './route.ts';
export type { Run } from './route.ts';
export type { Run, Skill } from './route.ts';
export { createSkill } from './route.ts';
export { CustomError } from './result/error.ts';
export * from './server/parse-body.ts';
export * from './router-define.ts';

View File

@@ -1,24 +1,22 @@
export { Route, QueryRouter, QueryRouterServer, Mini } from './route.ts';
export { Connect, QueryConnect } from './connect.ts';
export type { RouteContext, RouteOpts, RouteMiddleware } from './route.ts';
export type { Run } from './route.ts';
export { ServerNode, handleServer } from './server/index.ts';
/**
* 自定义错误
*/
export { CustomError } from './result/error.ts';
export { createSchema } from './validator/index.ts';
export type { Rule, Schema, } from './validator/index.ts';
export { App } from './app.ts';
export { createSchema } from './validator/index.ts';
export type { RouteContext, RouteOpts, RouteMiddleware } from './route.ts';
export type { Run, Skill } from './route.ts';
export { createSkill } from './route.ts';
export { CustomError } from './result/error.ts';
export * from './router-define.ts';
export { ServerNode, handleServer } from './server/index.ts';
export { App } from './app.ts';
export type {
RouterReq,

View File

@@ -1,5 +1,5 @@
import { nanoid } from 'nanoid';
import { RouteContext } from './route.ts';
import { RouteContext } from '../route.ts';
export class Connect {
path: string;

View File

@@ -2,6 +2,8 @@ import { nanoid } from 'nanoid';
import { CustomError } from './result/error.ts';
import { pick } from './utils/pick.ts';
import { listenProcess } from './utils/listen-process.ts';
import { z } from 'zod';
import { filter } from '@kevisual/js-filter'
export type RouterContextT = { code?: number;[key: string]: any };
export type RouteContext<T = { code?: number }, S = any> = {
@@ -90,6 +92,22 @@ export type RouteOpts<U = {}, T = SimpleObject> = {
};
export type DefineRouteOpts = Omit<RouteOpts, 'idUsePath' | 'nextRoute'>;
const pickValue = ['path', 'key', 'id', 'description', 'type', 'middleware', 'metadata'] as const;
export type Skill<T = SimpleObject> = {
skill: string;
title: string;
summary?: string;
args?: z.ZodTypeAny;
} & T
/** */
export const createSkill = <T = SimpleObject>(skill: Skill<T>): Skill<T> => {
return {
args: {},
...skill
};
}
export type RouteInfo = Pick<Route, (typeof pickValue)[number]>;
export class Route<U = { [key: string]: any }, T extends SimpleObject = SimpleObject> {
/**