refactor router system and update version

- Simplified Route class by removing validator functionality
- Added AppRouteContext type for better type safety
- Added forward method to RouteContext for response handling
- Replaced queryRoute with run method for consistency
- Improved Server class with proper cleanup methods
- Updated Mini class to extend QueryRouterServer properly
- Removed lodash-es dependency and nanoid random import
- Added deprecation warnings for older methods
- Enhanced route handling and middleware execution

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-06 12:30:47 +08:00
parent ef0faf84b1
commit c692061b23
6 changed files with 99 additions and 228 deletions

View File

@@ -11,8 +11,8 @@ type SimpleObject = Record<string, any>;
export function define<T extends Record<string, RouteOpts>>(
value: T,
): {
[K in keyof T]: T[K] & RouteOpts;
} {
[K in keyof T]: T[K] & RouteOpts;
} {
return value as { [K in keyof T]: T[K] & RouteOpts };
}
@@ -95,7 +95,7 @@ class QueryChain {
* @param queryData
* @returns
*/
getKey(queryData?: SimpleObject): Pick<RouteOpts, 'path' | 'key' | 'metadata' | 'description' | 'validator'> {
getKey(queryData?: SimpleObject): Pick<RouteOpts, 'path' | 'key' | 'metadata' | 'description'> {
const obj = this.omit(this.obj, this.omitKeys);
return {
...obj,