This commit is contained in:
lik
2026-05-25 12:02:28 +08:00
parent 17c8f0e1e8
commit 2c6efee887
13 changed files with 2337 additions and 0 deletions

38
routes/index.js Normal file
View File

@@ -0,0 +1,38 @@
import Router from 'koa-router';
import { HandlerUser } from '../handler/users.js';
class ApiRouter {
constructor() {
this.router = new Router();
this.handler = new HandlerUser();
this.setupRoutes();
}
setupRoutes() {
const userRouter = new Router({ prefix: '/user' });
userRouter.post('/wxgetphonenumber', this.handler.wxGetPhoneNumber.bind(this.handler));
userRouter.post('/wxsignin', this.handler.wxSignin.bind(this.handler));
userRouter.post('/update', this.handler.updateUser.bind(this.handler));
userRouter.post('/signout', this.handler.signout.bind(this.handler));
this.router.use(userRouter.routes());
this.printRoutes(this.router.stack);
}
getRoutes() {
return this.router.routes();
}
printRoutes(stack) {
for (const layer of stack) {
if (layer.path) {
const methods = layer.methods.filter(m => m !== '_all');
methods.forEach(m => console.log(` [${m.toUpperCase()}] ${layer.path}`));
}
}
}
}
export default new ApiRouter();