https://github.com/nitin42/routes-getter
Walks through your routes folder and imports them to your project.
https://github.com/nitin42/routes-getter
Last synced: 3 months ago
JSON representation
Walks through your routes folder and imports them to your project.
- Host: GitHub
- URL: https://github.com/nitin42/routes-getter
- Owner: nitin42
- Created: 2016-11-09T13:04:19.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-17T06:11:45.000Z (over 8 years ago)
- Last Synced: 2025-01-12T23:11:19.852Z (5 months ago)
- Language: JavaScript
- Size: 21.5 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# routes-getter
[](https://travis-ci.org/nitin42/routes-getter)
[]()
[]()
> ***Accessible routes in your ExpressJS application***
An easy way of working with your routes in [ExpressJS](https://expressjs.com) applications.
It walks through your routes folder and imports them to your project.**Note** - It does not walk through the `middlewares` folder in your `routes` folder. Since they are used and shared by routes as further middlewares.
#### Table of Contents
* [Installation](#installation)
* [Examples](#examples)
* [API](#api)## Installation
```
npm install -g routes-getter
```## Examples
Assuming the `src` directory to be the application folder, this is how you will define the routes
```javascript
// src/routes/index.jsmodule.exports = (app) => {
app.get('/', (req, res) => {
res.render('../views/index.html');
});
}
```
`server.js` file in your app directory.```javascript
// src/server.jsconst express = require('express');
const loader = require('routes-getter');const app = express();
loader.routers(__dirname + '/routes', app); // Loads the routes in your application
```Check the complete example [here](https://github.com/nitin42/routes-getter/tree/master/example)
## API
### loader.routers([options])
### options
#### path
*Required*
Path to routes in your application folder.
#### app
*Required*
app should be instance of **express**
## Tests
```
npm test
```## Contributing
Add unit tests for any new or changed functionality.## License
ISC