Files
RSSHub/lib/api_router.js
NeverBehave 0792f7ba25 feat(core): first attempt to init script standard (#8224)
- lazy load
- rate limit per path
- init .debug.json support
- docs
- maintainer
- radar
2021-09-22 05:41:00 -07:00

27 lines
638 B
JavaScript

const Router = require('@koa/router');
const router = new Router();
const maintainer = require('./maintainer');
router.get('/routes/:name?', (ctx) => {
const result = {};
let counter = 0;
Object.keys(maintainer).forEach((i) => {
const path = i;
const top = path.split('/')[1];
if (!ctx.params.name || top === ctx.params.name) {
if (result[top]) {
result[top].routes.push(path);
} else {
result[top] = { routes: [path] };
}
counter++;
}
});
ctx.body = { counter, result };
});
module.exports = router;