Giter VIP home page Giter VIP logo

auto-load-router's Introduction

Auto Load Router

使用koa,按照路由文件路径,自动挂载路由,可配置路由前缀前缀,该项目实现基本后端三级分层。

Installation

npm install

Start

npm start

Docs

  • 通过配置根据目录结构自动挂载路由,

eg: configs/index

router: {
    prefix: {
      admin: '/api/admin',
      web: '/api/web',
      wechat: '/api/wx',
      statistics: '/api/stat'
    }
  }

prefix用于配置路由自动挂载。prefix中的key是根目录下routes中的目录结构,

routes
├── admin
│   └── user.js
├── statistics
│   └── read.js
├── web
│   └── order.js
├── wechat
│   └── notification.js
└── index.js

key对应的value值则是对应路由的前缀,比如这里的admin, 意思就是admin目录下的所有路由以 /api/admin 打头,再看user.js文件中的具体路由

 R.get('/users', User.list);

那么我们浏览器访问的地址为 http://localhost:3000/api/admin/users

auto-load-router's People

Contributors

wfsovereign avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.