diff --git a/package.json b/package.json index ccd4a68..f460dd7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "$schema": "https://json.schemastore.org/package", "name": "@kevisual/router", - "version": "0.0.21-beta", + "version": "0.0.21", "description": "", "type": "module", "main": "./dist/router.js", diff --git a/src/app.ts b/src/app.ts index 0830b2a..d221d4d 100644 --- a/src/app.ts +++ b/src/app.ts @@ -2,6 +2,8 @@ import { QueryRouter, Route, RouteContext, RouteOpts } from './route.ts'; import { Server, ServerOpts, HandleCtx } from './server/server.ts'; import { WsServer } from './server/ws-server.ts'; import { CustomError } from './result/error.ts'; +import { handleServer } from './server/handle-server.ts'; +import { IncomingMessage, ServerResponse } from 'http'; type RouterHandle = (msg: { path: string; [key: string]: any }) => { code: string; data?: any; message?: string; [key: string]: any }; type AppOptions = { @@ -100,6 +102,9 @@ export class App { throw(...args: any[]) { throw new CustomError(...args); } + static handleRequest(req: IncomingMessage, res: ServerResponse) { + return handleServer(req, res); + } } export * from './browser.ts';