generated from tailored/router-db-template
Initial commit
This commit is contained in:
48
src/dev.ts
Normal file
48
src/dev.ts
Normal 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}`);
|
||||
});
|
||||
Reference in New Issue
Block a user