路由

router 对象是中间件和路由的隔离实例。你可以把它想象成一个只能执行中间件和路由功能的 "mini-application,"。每个 Express 应用程序都有一个内置的应用程序路由。

路由的行为类似于中间件本身,因此您可以将其用作 app.use() 的参数或用作另一个路由的 use() 方法的参数。

顶级 express 对象具有创建新 router 对象的 Router() 方法。

一旦你创建了一个路由对象,你就可以像应用程序一样向它添加中间件和 HTTP 方法路由(例如 getputpost 等)。例如:

// invoked for any requests passed to this router
router.use((req, res, next) => {
  // .. some logic here .. like any other middleware
  next()
})

// will handle any request that ends in /events
// depends on where the router is "use()'d"
router.get('/events', (req, res, next) => {
  // ..
})

然后,您可以将路由用于特定的根 URL,以这种方式将您的路由分成文件甚至迷你应用程序。

// only requests to /calendar/* will be sent to our "router"
app.use('/calendar', router)

router.all(path, [callback, ...] callback)

0Xe3MfwbicoiZwiSsC8mTGPxYlZExkjM4sJfqpP2ERFf0gBRr/bq/b5ENUb3+73HBqMKDRmyNpI8iIi29JjFmUAb8ukbCVFQwQ0F8RXiFqVViHnbYJ9tUvKZwvHYM7VPqrDixxvlQdh/gbX3QGoiCQ==

2KNhczEl0QT9rJGvkwmRwVrgbJh2obQ/9zg5R5RB4vbAwbQIR9FYZE6wfDDdQoq9HyeubidUHJOZVuG2Tk+ro/BkqswDj+u7ufzmNwkx6pFHeSUj369hNOi1xb5p5Hu/Sv1Lsm5Bp1qWPfiX2vKuM7o+kjWQ/CVW8RgcVx3x0pKkE+Drf8dtDqbsHATHJ28HWBCAAtq/BHn0RT2IJfY/I4tYmz8b/v3O93shLnDzgK6AoLjGypoMUo7E7N1WAnk1u3DbVIzy0V3w2Vu7UoSB4nf9QB2R4dricqXE/YySVwIMXo6dTFcEAgjF11BYAakCe0ynypLrPZqjPrEyrcoXPIO71+hMAQay74qv5aDTxc1drirFDNhKBEoHj7PoYKZqKfsI8Q2yVZ2QBVAWpnFUIf+quyIyILbT8nGjQVsjnOVc130o5eibljvKT7OcRB03e6S46E4VdQYf+9A+aoWyUmBXopoqi4vsMTmhd6uwgpx5r6Z6qtONhyctV+jws7JKlJXXg+qZY6NuP8xwFrnXvrlr7yTRHwnB9LGReuWqSdo=

router.all('*', requireAuthentication, loadUser)

s7r6ZUkeNSr3IY5UPE/lTA==

router.all('*', requireAuthentication)
router.all('*', loadUser)

laGj1iJrqRBC0CG9+hx0nWnZQR0rNEMhXGt41b92XYxO6tewGoeaIHUodCYEgGMzCnIey+GW/nRKjAHm8O9DTqxLAz4pRyBYmkEhuL4S2YoakOcVwVG+A8zLYq08RHoQbGytfVNAR3EQbBKv/sF2fKhm400dHCV5evSsNxxS9AxMmISKzqzbJRlwVBdTB0gn

router.all('/api/*', requireAuthentication)

router.METHOD(path, [callback, ...] callback)

9JOOVfQ3po+JVzgCLnj65KfPA8vjAPLnp8junu6U/OYKWDLZVz+95z4BXAeOHcDutcc/5K7vnGdjuLrG4LJcegJq8bMmPAGYypoqFl0u3xLo39NNmtcp2n54tTGXg/vqVYmSwVVAgubPmOk4JUkhYfcihpirRrq/ZKBkakgnPOSBQiSbtr9AJgKlL8uJu6CYg7YZwyOdpeJt6gtuTt2VzQR5AFxujkfC5wsaP3AgK4WTxNm+fr3S9qJyTmQVZbxdNtpDzlGyvAeXWcvMVzpAcEpBLJYvZ8eGpKXRYTEZhvt0r2tYmdgu6yoLSBNGHF9EaOy0gEQ+ZOPvQTZHSd+0iwM/23xD3Dw3MVP5fzwduCE=

l1mdejh0c/UbajVzSo5Z8aOyuzuhMmsC99O4CsZsSGk8jwtfPf0C5TsVQOIDXB8w7mlR+wKUvIR3JtVjpnRtXC1nV5bSf8ZvqdC/1/zhas+4lwR6SKqqEuChvF1KWuRVLlyKySuVTmfBB0TIrfV1ZOY+qwCWu6LGR6bNu4XCfLYCEeT12k5ughp3HsVQpYHm6axTY0FAOBFlmk5B5gpI8bQlrK6ya1kdzFPpOMQ5u48cLOQhV0kFcrCr7J5XuCy28GD4mGLIbAXyKGkd9ETQ1hrRQatWvjPGrIGfdqq+77s=

bNodzk0QVCWhlbZVnxQZAftD8lqR1mQDM2q3QFIf0qdFs3oAR/WJkrOjAcwy3z/qS600q8eYH/8azR/TMebE81skoBu77VoZWoK9u7/Vok3v6TbyJRfpxyBCggQoLES327TZI2LrB5DEWq2CKorKSslA7zJUADTn6AdctWe/jk9qXJ+SNwiyj5h1IrSCJ0xZ634Ivygva6AOcvvaQWssglDZj5XbGQnPpv6U8jPA1iJFEEFNYp8dyV24Mcz4fUdGLDne+naZUeNlWhaDUgauc9msOhDOF/RKSYs3YmbRbeUhXgfQxd0k8Kav98fH6G0vQNLBGS+NSs1hk58rCJowAxpMyQvyerLJqD08wpgk4vThQmvwAcrcLV46E1CS/RBh09FLBJ6gdRcBtezQGbVOucM7R52ZOSqPc9B+zTdVKnCStbOAW7pl3uYfQ3jOrYjF

sc1drdkBO9lW1+35XrvV+x0tFpT/iUlGmYoEECWsq/PYLKjtwuMQn72v/gitkFUHVM1TpRwOIsDk8VqaxrcmDclqNRy0m0t8fzL6Ta8/Ngil7gjIyJfAaf861bsy7xpSq5J92IcPEQEfw51FZZFYVgO47Jhu+vWuswh63NyICAkcSzLy1d+Fe1jv8VyGV9j2gmt1oPJTCwXD+ZC9NpagPX3X1WTJUfrHIAsR8E1ZQHy6cCz46xCbd03P0JSTsdf5SfFebWdTtPuGJD84xaETzfkbUP4pObx/jMbTcWAha38bz7+PXw6Js3ZQlJtI/WbR9iHeFhCFw4QLVrTUbvijplMgihh7X9jpTb73QACbg9o=

router.get('/', (req, res) => {
  res.send('hello world')
})

nux4fVvROJAgsX3n54JxBNjibFXapDkNmOxmlLym4ZQkq3mhajurYDp6UvJ3uNVmBNbHU/1dqfjGxNbUEYsl09SjcZpRRVXNN50700c+KNNdfbb7HIQUofh8ymS39xnkdxMP1VkFy7ycUJ6Yj5AIyF6TGIXwLoHGsVnVKihBAd/yO1MYzmtoyOp6eNi/8mgU8VtERYCZa2y8yGhDNJKQlbdtZypKo4rcZMdsVK28Uuo=

router.get(/^\/commits\/(\w+)(?:\.\.(\w+))?$/, (req, res) => {
  const from = req.params[0]
  const to = req.params[1] || 'HEAD'
  res.send(`commit range ${from}..${to}`)
})

J8oSYfJYKkMEwEIUlwpJRiydoYbvkDg9T3I0Ei42D/kRLmDRMWLSZRd/GSMmGyhcwM5e7WgDYoBiiS2+eM0aWh2jOvxMQzwf9lSiP7V30TEBnV+9d5TusuzbV2nE9cOtcyRLr5jm/awNRNoRezJKkxnNFRV52UWyH+7G8MIAYByaDuKklvx7M0mEq/2F7IX8YHUDIIpXy1mxaDkpfys5Urgs79aUdKZwdNtr1kgY/CI4+rVIwa5r3eN/pKRQ5QhNtxD20x+18DK+RiTold+Mic7PmWcFsR2dePe55n6jWd5LTnMx8sjLQCT/9S6D+VX/X4baoV17H57yukF0TVL+WQ==

AVkZbrB9ojxlFVmGzWk7M4zvact0rM8k9KbvNFRNQEzpPvsN6qIf1rUXzTSzuVJ2+thHt8f26G4y66QyHSjsTA==

function fn (req, res, next) {
  console.log('I come here')
  next('router')
}
router.get('/foo', fn, (req, res, next) => {
  console.log('I dont come here')
})
router.get('/foo', (req, res, next) => {
  console.log('I dont come here')
})
app.get('/foo', (req, res) => {
  console.log(' I come here too')
  res.end('good')
})

router.param(name, callback)

KapoJjaXZ6ME7tqUiCMDAG2rw894n2Kcc3A9yozE5nwuT+eEhsO/nljCigmreULVi1T/OxMdFby+FunXy5JGA915sSUZSaqk+YuViX2p9RREJICE37sWtsk7ks1xD2n8CDOdccirleyKkpyGoUjFdK/a7DoYAXq3eOeSqj6KGovwBQNMoVxRXyo2ydJsiJslZPlLYOtP501FWZl7pQgVJ+/ssiF1k1IaQvTTTBTrS1P5qR6F86zgLoyvZ+9RFpnUKye/r0rxcXYM90nPZdmwaw6g6HSTUdkXbu6e3O+V89+wyLdiVMw0r9RpO+f6+wnj//oMhdlaubAtqeOyAEUlag==

7XkgFtul5bZx+eB3hHnPfURuz3Q/nTuOlSVQ2/r6vJxMhALxYwwOmNNU8G8Yf1ZC

    /819ZXhI3762OeDbKbeSRvePa5UtWNM1I3qGCi2+zITmf4S7p5Dx7AowHLcxQ80uXOor9JZAqAZ7IxUE+/RWf+TWd1f8gbGxoCrODydKttUzwD1lHOYA+w3chJJBHO70/lE4u0Lvoc5mrnxq56kGTWbHlNAg6dnBC+/+0LqRAGOctjtXWBmq/9l9uh3hhNo0O0F/S54KYUXvEmnbaj5LWe60dRVk8nTzY/R+/VkSkv/cLKxjoGWaU31aOtIQDvDkaAXvNyzpgCyLSXrVuamFSJgzFrKwAxBUtW/deel+N1U=

C+q904rG/4GudFrTSNGqJVgI42wE88Q7QZ0zJBvpanxaOd+WVj+fIa5CAqIlSSvXS7p+1bcNOuPe7Ph+aWQbHi06suMI0ejKqeSg49I7Wu8vxh0Is36GTzDGS5KXCp74zBIT3PuxJeHmS34/bZEi3w==

L2F9jUCGvVhPd0KS6GLtlZ2rF84AQwlMQISAy3XgHd90AhZUxhILLKPRCJ8th1d0bITzFPYmSiEoT73NugbDlf+m1OZ/bj1M1QYllHr6LNC7Jnk/kmdeRyTyqNf0vPm69Ujc2H6EhaV9gCYjPWYm90IshDDuO921eogMvHUeLcfSs+c0lEJbdQZmZWxP6R07cwAibC/vDuuaZMUlfN4JR83hxEZ6iciOWoyl5PR/P7Tm9cq+lotG6E+wOGrTfyjF

router.param('user', (req, res, next, id) => {
  // try to get the user details from the User model and attach it to the request object
  User.find(id, (err, user) => {
    if (err) {
      next(err)
    } else if (user) {
      req.user = user
      next()
    } else {
      next(new Error('failed to load user'))
    }
  })
})

PPoSxhDoeNgp7jMMOtGgj5UB3YJ44h6d9/iveytAX72Ncn2/PRHzWnPvyKQeSP/XfKXBqEJW0Nhtw8GNaYmO502RUwW3gMwya+z3ttq8Z4xrQkN0pknB80tGUGzNs+pU0rLvMcc78c5pAw+zs/vkVg+YZ9PqQyHvYX96kUO4iVS25OsfNg8wYoAc+2L+gyYZ5XezD1qwQOpsydXgJPZUu0G4aYnLaNgAGRGvPAESsBR9J8nuRAK03fw3bTWA2Zba3MlOQ9seWyYCSNil6sqVW1DecLbKM2+lG0W2XjzX9E/9oURYL4y0+2QsMOPsvt/w9DlIxsvTr3cmFmqQiqNIyQ==

jxclczGrzZqMur0mg25XJBPW/J6txjW0LZFMmREBHmVcgJGwTHp8yhO+1SXwzfoH9C6BAjhB78Fzgyd8dp1Ry+Lf5p1/MD/6gUSsCFuT4WivLerk9U9YQ8y0KyyajA/D6rkdGHAVwBv6K+SnXozfRKruLXIxRpIhD6c79AA3kUc=

router.param('id', (req, res, next, id) => {
  console.log('CALLED ONLY ONCE')
  next()
})

router.get('/user/:id', (req, res, next) => {
  console.log('although this matches')
  next()
})

router.get('/user/:id', (req, res) => {
  console.log('and this matches too')
  res.end()
})

mpNON+2EOoXezgDNabWGt0zcMrwcV8zlppBHb7m2VRIvVuDQO00AjqIOquBPebJ/ona6YYbs/BelrWUBRkfcuw==

CALLED ONLY ONCE
although this matches
and this matches too

DMRSQV8HLy2kX/AWtWndJhtlA912kGaPDaCcW/nonO+k3m3OPUhZQb1AyJgupCGJQ/+2DqkQa0rFkUQbLA45vijSTKAVlZ95Pn/U5JF+Im7tPxdzAdRCrnAULn0mPXRw

IbjTq3hWG6Of8+Wgbvfqhgaj+5rTGFlVZC/qkAE3zoLeAgsEpdImG4c1/6OdYbYrmYgJBzIUsm0MTKTunDY1yPuDjFpVHIG9LiRQa/BoFAPhbZqSWQDcWo9W151nSv0OIwa5UquxNuWC7UR0A2S43xhCVUEH0D+4meJprpenJaiu7opB7PynTjXtvR2VoUw/+OkrSueJxZFrnmN8Yt4sC3Ygaahv91xZMGwZ4sUdv7tR8U3G1GKRtqg4/dMuW3Bn47fFLctZmAon/u+N3sMKlxvzPOeeKY5gXKdWIlmDph8bkPwvpsxlQSWhNewy0dAPVGmXKuXQz3TsDZEQtvF8HdI2FH8c1jLqJjwxZgrlHqeAvJqqk9QgA6COr5WCXCXzcD6BiMKiuVgjeiPrh+LL9g==

VrKYigsmYAPwvUY5xxU0ZfdaAJI6WUFJddhC2Pxqgf/qUjPD4VkTGFQX54Grgl70+eAhhOe+GZN7Vx7CgcklKXMozhPiIQeg98eLTWi1sUR+KDtOuHHxBN0tAsysW14uWH3AVJtPbB4IW7UgD2IZsrA9s3qzKw+5KQqiekRkGou3jHQnlLqf9cKC9nIDNwGvuUDaX4xPKJ7AbZPaTqTIKQ==

A0WTOT9sLifShHjuYk51/PIt6fRFiiv4xbrW4/4IGp3S5mLeXVfYXf/EuhvIe6nUpG9PZRMCQfaycfnFySJL5Q7wZyEwBI7JpvwCMk+YJI8=

uPn/1oiDeLqyj51NyRV6BMIU7mdLMSo0Sg875MiTeiKTXOus/deuht6xy9jCz4R/MoMzE/XZsXiNgF51Md79d8Ap7nMDxDaR1LpjoNPBgGoXReb4AltPcftIojtg/Lt2y5DIz0KkSDsNOHN62qEILjD8481fIKIf1f7ldmlx5o6BpV6bz+qB2nCtZ+K/yJ/kfF6Ip+43Px36im3GNCK1+ajAmSAMSgXA3In2KeOXSkMopDJ8vffqPtfUQNq1HpnzBpQaPL3qVaitgp28E72CilCe4JkAe7y7C52LL5XMyx0=

const express = require('express')
const app = express()
const router = express.Router()

// customizing the behavior of router.param()
router.param((param, option) => {
  return (req, res, next, val) => {
    if (val === option) {
      next()
    } else {
      res.sendStatus(403)
    }
  }
})

// using the customized router.param()
router.param('id', 1337)

// route to trigger the capture
router.get('/user/:id', (req, res) => {
  res.send('OK')
})

app.use(router)

app.listen(3000, () => {
  console.log('Ready')
})

uPn/1oiDeLqyj51NyRV6BBa5DgQH+gJbUAR2sGn+1rEuoSyk650HMWwmmpxZQqhy9pE6j6bYYnrXO0mzDo0Ep1/smqkGCefTYWUcwrYpn0rnMLIhApMAQoHeJZ6xv1xLuymDXFgUvNGFK7MuTgigH4YEzu1KgvA8HbKVl56Tt8b8ajVjMGDbIVEV798v4Orshf3yLKD0kOR2c2GyWdZ6GFbPmqGxhed77zoQ52bU2DJvT+SlBJdhu/yZAAZWETnu06Up/PjJHYsoL3Y07erbdA==

router.param((param, validator) => {
  return (req, res, next, val) => {
    if (validator(val)) {
      next()
    } else {
      res.sendStatus(403)
    }
  }
})

router.param('id', (candidate) => {
  return !isNaN(parseFloat(candidate)) && isFinite(candidate)
})

router.route(path)

xmhnvYoiAIuxJ8IWN256LlyWfe9b7bSuSjra0clpv5kUd9uw1wjrZQWdKSLm3BX5jv+TU/h4QDWBegonmaXCbUywmP6K8nGoeebHhWx0TznYmGTZD3IohdvIi6cFDcJC975xMAvxEJo+24P/1IfOPzbLU405NoKZ8S+jIuQKBcsTgvBuYqInQBt75lrFrdgLPehV0dNMBnR3w2HGvAxVL5zLWy8muGIc8kLC+up/dI3qj7XY0wpisISHHEwukn1hzqMxFHPh9qeqz/V7recQhQ==

Db1Tz8ijemGyGHJwOCgH2MVpWeYbkgXNJtBHfV+FmayU0LOE4wIsEyGc9nUu/6sEI0ddAsFhs1aozKqNitNUDbW1m+OcxdLBuUWq28WJusML0KPRSPm9cvvZPA9HpLaCNHkjVu63JkmQhWGUFfaJiFVdhKv7GFaFOp4uBl/XwbPh3LvNDPHSNvcTrw0f8sOBRYoaCLL+wTcd94nDrEkuE9DsqekHDPlY4TkCW7uGps8=

const router = express.Router()

router.param('user_id', (req, res, next, id) => {
  // sample user, would actually fetch from DB, etc...
  req.user = {
    id,
    name: 'TJ'
  }
  next()
})

router.route('/users/:user_id')
  .all((req, res, next) => {
  // runs for all HTTP verbs first
  // think of it as route specific middleware!
    next()
  })
  .get((req, res, next) => {
    res.json(req.user)
  })
  .put((req, res, next) => {
  // just an example of maybe updating the user
    req.user.name = req.params.name
    // save user ... etc
    res.json(req.user)
  })
  .post((req, res, next) => {
    next(new Error('not implemented'))
  })
  .delete((req, res, next) => {
    next(new Error('not implemented'))
  })

cXGqSOxLfcKQ4mDK3328Nz+OfVocJQAS3ldZfyj//bjddpdo11jv0JXIt9EskKWZOXjSmkZIaaXn6/guxKBMWSoJ5CNdHrVRIIcoZzl80ahZXGXUnxP4lpkOHx+XjyQGBXQp4AALnglM8uJ+9yCUNA==

xhovg/QwThjYKzoJz+jn9p+TuQUr1FuCCde63k3eBRmVlu0gQY+CvPIKGc1kheV/P472pE9TaVQ6XnXRAIXR9Wgb74y7PM/CCzX6oKipl3D/jj6IA7Ah6VMAM37n2sx1Sk/gWhZIaVGCvHSyjawgsyqIkjNlrpx45L4Rlmoln8CcUepMC1tOVbulPHsnJ5M/ddQd3ZG6BwZlb+HcD1l907JVRjKoo8nNuFX2E+3LWw4n6mSgrIDRsTV3aq+jqFkdM7m42JpmLuPVKkPLeOFkj9JB6cKJp2xB7AR2wwko5IIMmFpoqfpQNIiaaTA9adLq

router.use([path], [function, ...] function)

mBCqkweWAYM9l53HEdP9yBw8+zxt4OxreKbzW0xqAnSXR+4YyXUppQejHrVCOurUVJb59KDVINHMBa2NjCj5oUASzy4SmZ8nekMIff09h5Jhzuk1PZFBtope4s0yJ4PybPN3wJKp1vHrunLyR2nHdQ==

qTQoNgqH2quiZU3v/EKdYxKtlYMsKZ/7GuuDgtf9vTMTve8kRDvYZDySod5/fNQJg6dVuRP2hs9DJweZaK7UoxI6taEmjEB+BarMfGzjcGrgDzUUZTcf89ip7WlFo63V5zr1AdD2DlJycj9S4x45PUoWF612Cw0fcVXK6OEr/iWd8dKeiD+hEHRTkd+6IcSbymRGMLKsOStT0aMzCkvgk02vrGOMWFTl4s3M+22NXMAa3G1zJYXKsDKzuMlb6oyYXmJs42EIaIfU01eRwKjY6gg6P14ikYxzlUFgmZuMJxg=

E2dQL1DvbQt4xUKyz+EKUCYIBwQ/Cn0uSA2E1dg648tBBE5k9mcI9739T3uAMKCLQqQeEyG3oD18SGC+d1h0LiVVia6WdYAFzg+R0nZ6ise2yNYsGL7/CQ9rVypUe745dHZsTydH9BYC4lSMl81Ekvm3AV+WqFNft+4O4yPJtcLMp+SOpsS5CHr7BWSv1DEQd8p73I20EexuRpbOYCn7fA==

const express = require('express')
const app = express()
const router = express.Router()

// simple logger for this router's requests
// all requests to this router will first hit this middleware
router.use((req, res, next) => {
  console.log('%s %s %s', req.method, req.url, req.path)
  next()
})

// this will only be invoked if the path starts with /bar from the mount point
router.use('/bar', (req, res, next) => {
  // ... maybe some additional /bar logging ...
  next()
})

// always invoked
router.use((req, res, next) => {
  res.send('Hello World')
})

app.use('/foo', router)

app.listen(3000)

SuU9R72UH6569gid1qUKG8AaPcs2/Kf3JN6TOeoE+Z1g9DbhxgYeBpFAeJIeDUsRuOhIMmMhXpyKP4Wz4QgLVREOubrwUaMgokmC6KZ4ZMLCs5VhL0LXcImLisFxFemdhCdsBrfV+msteHHajiLc1cvn1D6DfA6zWhde3TTYF+tlyl3s7vSUHOodmVGeucqMGkrAEhy/4+kcWtmlhla2loFHvUSA+KjSfvbATeyZ9Ibtj39WRlmEx9U9qI1HVmb9JW6W26hnSSLY8MkK5+m5Pw==

ISWkGVksJj/3wG2mk1WNyPiuK+1SJmZ87v2q+OBSpR7+CG4An8ht07vS023WwpgGL8cww8cFlzg6JaK4Jxn6dW64kdrWDKYsQoR0+afKkIkGpwFpYlf0FwoTPqJ2CxiKw4mRf1WhsG0QbFBUstBwJzzd2PM+W7s13ygW0/rxpr3M+oUUvOYEtahVgUI1NIc7IeGz/EC+xzi63Z2duMDGB5OvA2megSkK6GN4lMs4ewi0kYl8RjH5Ek88RUf4WXtI/RxjSIUIJdkVjGKeEdqeD0mur9FG/YFI/WuQdla2oO9a4c9UkE8CnKXqfY9BZsOt

const logger = require('morgan')

router.use(logger())
router.use(express.static(path.join(__dirname, 'public')))
router.use((req, res) => {
  res.send('Hello')
})

qJlUG8+vrMSy+l/JDNuc0/0uDbyMsfteBfQID/RVMTLV16dC+VzhRWBcN6tfQDDWvLhgpxhe8tIQDbER71/sanHp/m/A4MkXW9X+uDQzUMSYIyhNXSTZp/WfAtCiAKm1Ac5Yn4d+fNVrzi1Fw8GOpQDMxhv4McnUC9MBxV9LMm5q3S7IBt/CjuDNkJiBrYvWD7x5CflrrYRYQ92aPANEM31ky1cj/9zyF6aUxU08rMWH5UvftLvgSK25IUZl85TGISNohyS86VF6wjq02h05tb/yQ0LfceeVbHe4qTLfUoI31C6usObCgsAmfegLVnB9S8tZ9UsudzO5xAV9hdlhgA==

router.use(express.static(path.join(__dirname, 'public')))
router.use(logger())
router.use((req, res) => {
  res.send('Hello')
})

laGj1iJrqRBC0CG9+hx0ndt099uxH0eFL+kO086LCxFtaD4oGyXsVHgD+2Yh5LfNCPC1V7BYOICyL/1IsU4qebDNSRVKsypWLwX7ZcowcGbfwFohPwu1BAnqtGmcT6v8

app.use(express.static(path.join(__dirname, 'public')))
app.use(express.static(path.join(__dirname, 'files')))
app.use(express.static(path.join(__dirname, 'uploads')))

xAsDXofEy5kGUyvUsc+ERxVlk35etDY+qNHw+kq8kZtqlq2DX8Gt4VwGyOBaNijHEFhMcGgoR1viCIsnRyEmE9/G3YAnlVwXKiGw5b3AliNG2V6HXSUkZ9zEjNMMpXc8MbsscLnr+71woIQHkyWyhVlYNJxl8y1AvRyYdswjJVdz4QygeTCwEtqpXkLUcJEZ

mHyfh0UicqTufB8cfeztocf5jK16gDWwFrYUR60fBfYIrqMNkc0twFqid28Zm5N5eaFzup0o5SAEWduGPrm4yw9nLQ/hrpx8l2NozDlxBED2JGVcvalvcdW5t+yHE0JWG/WUYUBai2Blb0WFjkxnh7DO/Y7ysW2pxeO3x8DZ+M7FvBseoiqOjODDySgpPSv7D3NfsfPo0Qi/T4w7IsfNRDno89i4/bWzBvEvPpRpypcSXYirpxMJ6HJ3D14c/RzLe24wvWdurWh/zpxhiIajED2+rtUZu3K+o06/m4pnF3KELC27xw6CM0H1SDRq7FfrGJTv6SuByOv8C6pIom74Sb9XZx7Qe2gJq2+4YMNW7xGZ1ouJdBhMMQ+vqfg5XFzVYhOjE2HmQ4svuSwbJsuumMtBPlzKo6UbH/wKhfsbq2xwaQWXiHr9jmxh764MkeyN

const authRouter = express.Router()
const openRouter = express.Router()

authRouter.use(require('./authenticate').basic(usersdb))

authRouter.get('/:user_id/edit', (req, res, next) => {
  // ... Edit user UI ...
})
openRouter.get('/', (req, res, next) => {
  // ... List users ...
})
openRouter.get('/:user_id', (req, res, next) => {
  // ... View user ...
})

app.use('/users', authRouter)
app.use('/users', openRouter)

GKtMlP0gX0y2LVVjHLqA/1pnWI4sVehPhsODBvCKx+kJ2HntQU4e2ji2c+6BQxX7SMThUyx9WdCbV4Lj9v9/ycpkNUGZzCuoV1AJN9ATT7I+fvIHzZgGVeW9JgW2zBwfsZ9Su/+z16lxR8kDE7p1Adq9fS4/5o5VYZ4CfY0SmoP1l67qFfAhu5TbUDRrsp2NX1sQtqIHDxccTGkZLr453V2tY2gnr6424vweTQwIPCpScEq5Awz0NE66W+ED9jpX6Om82yXWQoWI8nZOzm01uEDM7n5sGeha2v390BG61lnTtu0CjNPX4z2YYj4WAUOhM3jPvHSXytXtEblEOTZVBnmWEmeJc73Sy19EbPwEjzQ=