1.0.2 • Published 5 years ago
sfr-koa-routerscan v1.0.2
Simple, Fast, Reliable(SFR)
sfr-koa-routerscan
router scan for koa web framework
npm i sfr-koa-routerscan
Usage
const path = require('path');
const Koa = require('sfr-koa');
const fileRouterscan = require('sfr-koa-routerscan');
const app = new Koa();
app.use(fileRouterscan());
app.listen(8080);
Router file
name.router.js
const KoaRouter = require('sfr-koa-router');
const router = new KoaRouter();
module.exports = router;
router.get('/', async (ctx, next) => {
ctx.body = 'Hello, koa router.';
});
API
FileRouterscan([path], [regex])
- path default __dirname.
- regex default /\w+\.router\.js$/
app.use(fileRouterscan(
path: path
regex: regex
));
Copyright (C) 2019 Jkin.feng. Licensed MIT. For more details, please see LICENSE.