routers.js 575 B

1234567891011121314151617181920
  1. var errors = require('./components/errors')
  2. module.exports = function (app) {
  3. app.use('/api/users', require('./api/user'));
  4. app.use('/api/pages', require('./api/pages'));
  5. app.use('/api/upload', require('./api/file'));
  6. app.use('/auth', require('./auth'))
  7. // 404错误处理
  8. app.route('/:url(api|auth|components|app|bower_components|assets)/*')
  9. .get(errors[404]);
  10. // 前端页面渲染路由
  11. app.route('/perview/:id').get(require('./render/preview'))
  12. // 其他资源路由
  13. app.route('/*')
  14. .get((req, res) => {
  15. res.render('index')
  16. });
  17. }