@abnerlin/express-routes-loader

2.0.1-readme • Public • Published

Express Routes Loader

Load all routes in directory.

Installation

npm install @abnerlin/express-routes-loader

Usage

const app = express();
const expressRouteLoader = require('@abnerlin/express-routes-loader')(app);
    
...

Load all routes in direcotry

expressRouteLoader.dir(path.join(__dirname, 'routes')); // which 'routes' is directory path.

Load routes with specify file

expressRouteLoader.file(path.join(__dirname, 'routes', 'auth')); // which 'routes/auth' is file path.

Export url path

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

router.post('/login', function(req, res) {
        ...
});

router.root = '/auth';  // this is url path which must export.

module.exports = router;

Readme

Keywords

Package Sidebar

Install

npm i @abnerlin/express-routes-loader

Weekly Downloads

0

Version

2.0.1-readme

License

GPL-3.0

Last publish

Collaborators

  • abnerlin