@rill/webpack-router
v2.0.2
Published
Rill middleware for automatic routing using Webpack require contexts.
Downloads
2
Maintainers
Readme
A tool to automatically build a middleware for Rill based on a webpack require.context. Automatically routes all files required.
Installation
npm install @rill/webpack-router
Example App
const app = require('rill')()
const router = require('@rill/webpack-router')
// Setup all of your custom middleware (automatically routed based on file system path.)
app.use(router(require.context('./controllers', true, /\.js$/)))
Example Middleware
exports.get = ({ res }) => {
// Export the methods you wish to handle (in this case a get request).
res.body = 'hello world'
}
exports.post = ({ res }) => {
// Handle other methods as well.
}
Contributions
- Use
npm test
to run tests.
Please feel free to create a PR!