Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/goliatone/trackfinder
Express route finder
https://github.com/goliatone/trackfinder
Last synced: 11 days ago
JSON representation
Express route finder
- Host: GitHub
- URL: https://github.com/goliatone/trackfinder
- Owner: goliatone
- License: mit
- Created: 2014-08-02T04:58:54.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-01-15T18:24:48.000Z (almost 7 years ago)
- Last Synced: 2024-04-25T17:21:51.379Z (7 months ago)
- Language: JavaScript
- Size: 58.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE-MIT
Awesome Lists containing this project
README
# trackfinder
Express route finder and loader.
This library will autoload route files that finds under any specified directory.
## Getting Started
Install the module with: `npm install trackfinder`This library will autoload route files that finds under any specified directory.
Instead of doing this:
```javascript
const app = express();const routes = require('./routes/index');
const users = require('./routes/users');app.use('/', routes);
app.use('/users', users);
```You can do this:
```javascript
const app = express();
const TrackFinder = require('trackfinder');TrackFinder.register(app, {
path:'./routes'
});
```This will load all files inside the **routes** directory.
TrackFinder supports different route file formats. The most simple route file would look like this:
```js
'use strict';module.exports = function(app, config) {
console.log('- pets: register routes');app.get('/pets', function(req, res){
res.json({
pets: [
'Colonel Meow',
'Casper',
'Chase No Face',
'Cherry Pop'
]
});
});
};
```## Documentation
### Options
* [path](#path)
* [logger](#logger)
* [mountpath](#mountpath)
* [middleware](#middleware)
* [priorityFilter](#priorityfilter)
* [filters](#filters)
* [methods](#methods)##### path
* Default: 'routes'Path to directory containing route files.
##### logger
* Default: `console`
Logger instance.##### mountpath
If present it will be passed as the first argument to the call`app.use(mountpath, ...)`.See [express mountpath][express-mountpath]
##### middleware
This get's applied to the router, not to individual routes.##### priorityFilter
Function to order route files which determines the order in which the routes are mounted.##### filters
Function to filter out files from `path`.##### methods
### Routes
#### Route options
* priority: Property that will be used by `priorityFilter` and will determine route order.
* mountpath: See [express mountpath][express-mountpath]
* middleware: Array of middleware functions. This get's applied to the router, not to individual routes.#### Route file formats
Your route files can be in different formats.## Examples
```javascript
const express = require('express');
const TrackFinder = require('trackfinder');
const app = express();TrackFinder.register(app);
app.listen(3000, function(){
console.log('Express server running');
});
```## Release History
_(Nothing yet)_## License
Copyright (c) 2014 goliatone
Licensed under the MIT license.## TODO:
Integrate file finder stuff:
https://www.npmjs.org/package/file-magic
Order:
https://github.com/eladb/node-jsplugs[express-mountpath]:http://expressjs.com/en/4x/api.html#app.mountpath