This commit is contained in:
lik
2026-05-25 12:34:16 +08:00
parent c614b19b78
commit 1e7aa55533
986 changed files with 23880 additions and 0 deletions

38
api/routes/index.js Normal file
View File

@@ -0,0 +1,38 @@
import Router from "koa-router";
import { HandlerEscortRecord } from "../handler/escort_record.js";
import { HandlerResource } from "../handler/resource.js";
function 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}`));
}
}
}
function registerRoutes(app) {
const router = new Router({ prefix: '/health' });
const handlerEscortRecord = new HandlerEscortRecord();
const handlerResource = new HandlerResource();
router.get("/escort-record/my", handlerEscortRecord.getMyRecords.bind(handlerEscortRecord));
router.get("/escort-record/attendant", handlerEscortRecord.getAttendantRecords.bind(handlerEscortRecord));
router.get("/escort-record/:id", handlerEscortRecord.getRecordById.bind(handlerEscortRecord));
router.post("/escort-record", handlerEscortRecord.createRecord.bind(handlerEscortRecord));
router.put("/escort-record/:id", handlerEscortRecord.updateRecord.bind(handlerEscortRecord));
router.patch("/escort-record/:id/status", handlerEscortRecord.updateStatus.bind(handlerEscortRecord));
router.get("/service", handlerResource.getServices.bind(handlerResource));
app.use(router.routes());
app.use(router.allowedMethods());
console.log('API Routes:');
printRoutes(router.stack);
return router;
}
export default registerRoutes;