Javascript 将路由器逻辑拆分为单独的功能

Javascript 将路由器逻辑拆分为单独的功能,javascript,node.js,express,express-router,Javascript,Node.js,Express,Express Router,我在Node.js中有一个路由器的get请求处理程序,它有 很多代码: const express = require("express"); const router = express.Router(); router.get("/api/employees/employee-response", async (req, res) => { try { // First action with code // Second action with co

我在Node.js中有一个路由器的get请求处理程序,它有 很多代码:

const express = require("express");
const router = express.Router();


router.get("/api/employees/employee-response", async (req, res) => {
  try {

     // First action with code 

     // Second action with code 

     // Third action with code 

  }


catch(exp) {

  // ...
}



module.exports = router;
我如何将其拆分为小函数并从路由器调用这些函数