update: fix docs

This commit is contained in:
2025-06-20 16:20:56 +08:00
parent d2ebb5f488
commit 187900ad55
6 changed files with 45 additions and 10 deletions

View File

@@ -105,6 +105,12 @@ export class App<T = {}, U = AppReqRes> {
static handleRequest(req: IncomingMessage, res: ServerResponse) {
return handleServer(req, res);
}
onServerRequest(fn: (req: IncomingMessage, res: ServerResponse) => void) {
if (!this.server) {
throw new Error('Server is not initialized');
}
this.server.on(fn);
}
}
export * from './browser.ts';

View File

@@ -1,6 +1,8 @@
export { Route, QueryRouter, QueryRouterServer } from './route.ts';
export { Rule, Schema, createSchema } from './validator/index.ts';
export type { Rule, Schema } from './validator/index.ts';
export { createSchema } from './validator/index.ts';
export type { RouteContext, RouteOpts } from './route.ts';

22
src/test/static.ts Normal file
View File

@@ -0,0 +1,22 @@
import { proxyRoute, initProxy } from '@kevisual/local-proxy/proxy.ts';
initProxy({
pagesDir: './demo',
watch: true,
});
import { App } from '../app.ts';
const app = new App();
app
.route({
path: 'a',
})
.define(async (ctx) => {
ctx.body = '1';
})
.addTo(app);
app.listen(2233, () => {
console.log('Server is running on http://localhost:2233');
});
app.onServerRequest(proxyRoute);

View File

@@ -1 +1,2 @@
export * from './rule.ts';
export type { Rule, Schema } from './rule.ts';
export { schemaFormRule, createSchema, createSchemaList } from './rule.ts';