refactor: update router import path and add random ID utility

- Changed the import path for router types from '@kevisual/router' to './route.ts' in src/router-define.ts.
- Added a new lock file (bun.lock) to manage dependencies.
- Introduced a new utility function in src/utils/random.ts to generate random IDs using the nanoid library.
This commit is contained in:
2026-02-17 20:35:16 +08:00
parent b4f2615afa
commit a53e8c0bc3
9 changed files with 391 additions and 1300 deletions

View File

@@ -6,7 +6,7 @@ import { handleServer } from './server/handle-server.ts';
import { IncomingMessage, ServerResponse } from 'http';
import { isBun } from './utils/is-engine.ts';
import { BunServer } from './server/server-bun.ts';
import { nanoid } from 'nanoid';
import { randomId } from './utils/random.ts';
type RouterHandle = (msg: { path: string;[key: string]: any }) => { code: string; data?: any; message?: string;[key: string]: any };
type AppOptions<T = {}> = {
@@ -48,7 +48,7 @@ export class App<U = {}> extends QueryRouter {
if (opts?.appId) {
this.appId = opts.appId;
} else {
this.appId = nanoid(16);
this.appId = randomId(16, 'rand-');
}
router.appId = this.appId;
}