Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/will123195/express-pages
Automatic routing for express
https://github.com/will123195/express-pages
Last synced: 10 days ago
JSON representation
Automatic routing for express
- Host: GitHub
- URL: https://github.com/will123195/express-pages
- Owner: will123195
- Created: 2015-07-03T03:48:49.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-04T21:53:26.000Z (over 9 years ago)
- Last Synced: 2024-10-06T08:41:20.608Z (3 months ago)
- Language: JavaScript
- Size: 133 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# express-pages
Automatic routing for express
## Install
```
npm install express
npm install express-pages
```## Usage
#### index.js
```js
var express = require('express')
var pages = require('express-pages')
var app = express()app.set('port', (process.env.PORT || 5000))
app.use('/v1', pages({
dir: './api',
ext: '.js',
homepage: '/home',
helpers: {
beep: function () {
return 'boop'
}
}
})app.listen(app.get('port'), function() {
console.log([
'Running: http://localhost:' + app.get('port'),
'NODE_ENV: ' + process.env.NODE_ENV,
].join('\n'))
})
```#### ./api/beep.js
```js
//
// /v1/beep
//
module.exports = function () {
this.send({
beep: this.beep()
})
}
```