https://github.com/kripod/express-route-fs
File system-based approach for handling routes in Express.
https://github.com/kripod/express-route-fs
Last synced: about 1 year ago
JSON representation
File system-based approach for handling routes in Express.
- Host: GitHub
- URL: https://github.com/kripod/express-route-fs
- Owner: kripod
- License: mit
- Created: 2015-10-04T11:44:25.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2015-10-04T11:45:27.000Z (over 10 years ago)
- Last Synced: 2025-03-06T16:50:00.863Z (over 1 year ago)
- Language: JavaScript
- Size: 109 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# express-route-fs
File system-based approach for handling routes in Express.
[![NPM Version][npm-image]][npm-url] [![Travis CI Build][travis-image]][travis-url]
[npm-image]: https://img.shields.io/npm/v/express-route-fs.svg
[npm-url]: https://npmjs.org/package/express-route-fs
[travis-image]: https://img.shields.io/travis/kripod/express-route-fs/master.svg
[travis-url]: https://travis-ci.org/kripod/express-route-fs
## Installation
`$ npm install express-route-fs --save`
## Features
- Automatically load router files from a specifiable directory
- Easily organize and find your routers by using subdirectories for them
- Lightweight API
## Usage
__Syntax:__ `routeFs(app[, options])`
1. Define your routes in a directory
- It is encouraged to use separate files for each page in order to easily debug routing issues.
- Subdirectories can be used
- An `index.js` file of a directory sets the routing base to the directory's path.
2. Initialize the routers automatically
```js
var express = require('express');
var routeFs = require('express-route-fs');
var app = express();
routeFs(app, { routerDir: __dirname + '/routes' });
```
## Options
| Option | Description | Default |
|-------------|----------------------------------------|-----------|
| `routerDir` | Load router files from this directory. | ./routes/ |