feat: add export and import
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
"license": "ISC",
|
||||
"description": "",
|
||||
"dependencies": {
|
||||
"@abearxiong/router": "../.."
|
||||
"@kevisual/router": "link:../.."
|
||||
},
|
||||
"devDependencies": {
|
||||
"ts-node": "^10.9.2",
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { App } from '@abearxiong/router';
|
||||
import { App } from '@kevisual/router';
|
||||
|
||||
const app = new App();
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { Route, App } from '@abearxiong/router';
|
||||
import { Route, App } from '@kevisual/router';
|
||||
|
||||
const app = new App({ io: true });
|
||||
app.listen(4002);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { Route, App } from '@abearxiong/router';
|
||||
import { Route, App } from '@kevisual/router';
|
||||
|
||||
const app = new App();
|
||||
app.listen(4003);
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { QueryRouter, Route, Server } from '@abearxiong/router';
|
||||
import { QueryRouter, Route, Server } from '@kevisual/router';
|
||||
|
||||
const router = new QueryRouter();
|
||||
|
||||
|
76
demo/simple/src/test-two-app/app.ts
Normal file
76
demo/simple/src/test-two-app/app.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
import { App } from '@kevisual/router';
|
||||
|
||||
const app1 = new App();
|
||||
|
||||
app1
|
||||
.route({
|
||||
path: 'app1',
|
||||
key: '01',
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
ctx.body = '01';
|
||||
return ctx;
|
||||
})
|
||||
.addTo(app1);
|
||||
|
||||
app1
|
||||
.route({
|
||||
path: 'app1',
|
||||
key: '02',
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
ctx.body = '02';
|
||||
return ctx;
|
||||
})
|
||||
.addTo(app1);
|
||||
|
||||
const app2 = new App();
|
||||
|
||||
app2
|
||||
.route({
|
||||
path: 'app2',
|
||||
key: '01',
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
ctx.body = 'app2' + '01';
|
||||
return ctx;
|
||||
})
|
||||
.addTo(app2);
|
||||
|
||||
app2
|
||||
.route({
|
||||
path: 'app2',
|
||||
key: '02',
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
ctx.body = 'app2' + '02';
|
||||
return ctx;
|
||||
})
|
||||
.addTo(app2);
|
||||
const app3 = new App();
|
||||
app3
|
||||
.route({
|
||||
path: 'app3',
|
||||
key: '01',
|
||||
})
|
||||
.define(async (ctx) => {
|
||||
ctx.body = 'app3' + '01';
|
||||
return ctx;
|
||||
})
|
||||
.addTo(app3);
|
||||
|
||||
const app = new App();
|
||||
|
||||
app.importRoutes(app1.exportRoutes());
|
||||
|
||||
app.importRoutes(app2.exportRoutes());
|
||||
|
||||
app.importApp(app3);
|
||||
|
||||
app.listen(4003, () => {
|
||||
console.log(`http://localhost:4003/api/router?path=app1&key=02`);
|
||||
console.log(`http://localhost:4003/api/router?path=app1&key=01`);
|
||||
console.log(`http://localhost:4003/api/router?path=app2&key=02`);
|
||||
console.log(`http://localhost:4003/api/router?path=app2&key=01`);
|
||||
console.log(`http://localhost:4003/api/router?path=app3&key=01`);
|
||||
});
|
@@ -1,4 +1,4 @@
|
||||
import { Route, QueryRouter, RouteContext } from '@abearxiong/router';
|
||||
import { Route, QueryRouter, RouteContext } from '@kevisual/router';
|
||||
const qr = new QueryRouter();
|
||||
|
||||
qr.add(
|
||||
|
Reference in New Issue
Block a user