Initial commit

This commit is contained in:
media
2025-04-30 18:57:23 +08:00
commit 3f3f08cc4e
22 changed files with 6737 additions and 0 deletions

48
src/dev.ts Normal file
View File

@@ -0,0 +1,48 @@
import { app } from './index.ts';
import { useConfig } from '@kevisual/use-config/env';
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 config = useConfig();
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}`);
});