import { app } from './index.ts'; import { config } from './modules/config.ts'; app .route({ path: 'auth', id: 'auth', }) .define(async (ctx) => { ctx.query.token = '123'; ctx.state.tokenUser = { id: '123', username: 'admin', }; }) .addTo(app); app .route({ path: 'auth-admin', id: 'auth-admin', }) .define(async (ctx) => { ctx.body = '123'; ctx.state.tokenUser = { id: '123', username: 'admin', }; }) .addTo(app); app .route({ path: 'demo', key: 'demo', }) .define(async (ctx) => { ctx.body = '123'; }) .addTo(app); const port = config.PORT || 4000; console.log('run demo: http://localhost:' + port + '/api/router?path=demo&key=demo'); app.listen(port, () => { console.log(`server is running at http://localhost:${port}`); });