easy-router-express
easy-router-express is writed for building a easy router for express
Support
- Express
Installation
npm install easy-router-express# or yarnyarn add easy-router-express
Getting started
Use in Express
app
const app = 'express'
router
const router = 'express'
options
Attribute | Description | Type | Default |
---|---|---|---|
Path | Router Folder 's Path | String | `${__dirname}/router` |
Prefix | Router 's Prefix | String | Null |
Proxy | Router 's Proxy | Object/Array | Null |
Proxy
Attribute | Type | Example |
---|---|---|
method | String | 'POST' |
Func | Function | (req, res, next) => { next() } |
Example
server.js
const Express = const EasyRouter = const app = const router = const path = __dirname + '/router' app
router/demo.js
module.exports = (router) => { router.get('/test', (req, res) => { console.log('this is a demo') res.status(200).send('OK') })}