mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 05:59:00 +08:00
feat(core): first attempt to init script standard (#8224)
- lazy load - rate limit per path - init .debug.json support - docs - maintainer - radar
This commit is contained in:
27
lib/maintainer.js
Normal file
27
lib/maintainer.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const dirname = __dirname + '/v2';
|
||||
|
||||
// 遍历整个 routes 文件夹,收集模块 maintainer.js
|
||||
const maintainerPath = require('require-all')({
|
||||
dirname,
|
||||
filter: /maintainer\.js$/,
|
||||
});
|
||||
|
||||
const maintainers = {};
|
||||
|
||||
// 将收集到的自定义模块进行合并
|
||||
for (const dir in maintainerPath) {
|
||||
const routes = maintainerPath[dir]['maintainer.js']; // Do not merge other file
|
||||
for (const key in routes) {
|
||||
maintainers['/' + dir + key] = routes[key];
|
||||
}
|
||||
}
|
||||
|
||||
// 兼容旧版路由
|
||||
const router = require('./router');
|
||||
router.stack.forEach((e) => {
|
||||
if (!maintainers[e.path]) {
|
||||
maintainers[e.path] = [];
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = maintainers;
|
||||
Reference in New Issue
Block a user