feat: lacking config tips, close #2695
This commit is contained in:
+13
-43
@@ -1,7 +1,5 @@
|
||||
const Router = require('koa-router');
|
||||
const router = new Router();
|
||||
const config = require('./config');
|
||||
const logger = require('./utils/logger');
|
||||
|
||||
// index
|
||||
router.get('/', require('./routes/index'));
|
||||
@@ -113,14 +111,10 @@ router.get('/mzitu/post/:id', require('./routes/mzitu/post'));
|
||||
router.get('/mzitu/tag/:tag', require('./routes/mzitu/tag'));
|
||||
|
||||
// pixiv
|
||||
if (config.pixiv && config.pixiv.client_id && config.pixiv.client_secret && config.pixiv.username && config.pixiv.password) {
|
||||
router.get('/pixiv/user/bookmarks/:id', require('./routes/pixiv/bookmarks'));
|
||||
router.get('/pixiv/user/:id/', require('./routes/pixiv/user'));
|
||||
router.get('/pixiv/ranking/:mode/:date?', require('./routes/pixiv/ranking'));
|
||||
router.get('/pixiv/search/:keyword/:order?', require('./routes/pixiv/search'));
|
||||
} else {
|
||||
logger.warn('pixiv RSS is disabled due to the lack of token, api key or relevant config in config.js.');
|
||||
}
|
||||
router.get('/pixiv/user/bookmarks/:id', require('./routes/pixiv/bookmarks'));
|
||||
router.get('/pixiv/user/:id/', require('./routes/pixiv/user'));
|
||||
router.get('/pixiv/ranking/:mode/:date?', require('./routes/pixiv/ranking'));
|
||||
router.get('/pixiv/search/:keyword/:order?', require('./routes/pixiv/search'));
|
||||
|
||||
// 豆瓣
|
||||
router.get('/douban/movie/playing', require('./routes/douban/playing'));
|
||||
@@ -164,20 +158,12 @@ router.get('/zcfy/hot', require('./routes/zcfy/hot'));
|
||||
router.get('/jinritoutiao/keyword/:keyword', require('./routes/jinritoutiao/keyword'));
|
||||
|
||||
// Disqus
|
||||
if (config.disqus && config.disqus.api_key) {
|
||||
router.get('/disqus/posts/:forum', require('./routes/disqus/posts'));
|
||||
} else {
|
||||
logger.warn('Disqus RSS is disabled due to the lack of token, api key or relevant config in config.js.');
|
||||
}
|
||||
router.get('/disqus/posts/:forum', require('./routes/disqus/posts'));
|
||||
|
||||
// Twitter
|
||||
if (config.twitter && config.twitter.consumer_key && config.twitter.consumer_secret) {
|
||||
router.get('/twitter/user/:id', require('./routes/twitter/user'));
|
||||
router.get('/twitter/list/:id/:name', require('./routes/twitter/list'));
|
||||
router.get('/twitter/likes/:id', require('./routes/twitter/likes'));
|
||||
} else {
|
||||
logger.warn('Twitter RSS is disabled due to the lack of token, api key or relevant config in config.js.');
|
||||
}
|
||||
router.get('/twitter/user/:id', require('./routes/twitter/user'));
|
||||
router.get('/twitter/list/:id/:name', require('./routes/twitter/list'));
|
||||
router.get('/twitter/likes/:id', require('./routes/twitter/likes'));
|
||||
router.get('/twitter/followings/:id', require('./routes/twitter/followings'));
|
||||
|
||||
// Instagram
|
||||
@@ -185,13 +171,9 @@ router.get('/instagram/user/:id', require('./routes/instagram/user'));
|
||||
router.get('/instagram/tag/:tag', require('./routes/instagram/tag'));
|
||||
|
||||
// Youtube
|
||||
if (config.youtube && config.youtube.key) {
|
||||
router.get('/youtube/user/:username/:embed?', require('./routes/youtube/user'));
|
||||
router.get('/youtube/channel/:id/:embed?', require('./routes/youtube/channel'));
|
||||
router.get('/youtube/playlist/:id/:embed?', require('./routes/youtube/playlist'));
|
||||
} else {
|
||||
logger.warn('Youtube RSS is disabled due to the lack of token, api key or relevant config in config.js.');
|
||||
}
|
||||
router.get('/youtube/user/:username/:embed?', require('./routes/youtube/user'));
|
||||
router.get('/youtube/channel/:id/:embed?', require('./routes/youtube/channel'));
|
||||
router.get('/youtube/playlist/:id/:embed?', require('./routes/youtube/playlist'));
|
||||
|
||||
// 即刻
|
||||
router.get('/jike/topic/:id', require('./routes/jike/topic'));
|
||||
@@ -239,25 +221,13 @@ router.get('/v2ex/post/:postid', require('./routes/v2ex/post'));
|
||||
|
||||
// Telegram
|
||||
router.get('/telegram/channel/:username', require('./routes/telegram/channel'));
|
||||
if (config.telegram && config.telegram.token) {
|
||||
if (config.imgur && config.imgur.clientId) {
|
||||
router.get('/telegram/stickerpack/:name', require('./routes/telegram/stickerpack'));
|
||||
} else {
|
||||
logger.warn('Telegram Sticker Pack RSS is disabled due to the lack of token, api key or relevant config in config.js.');
|
||||
}
|
||||
} else {
|
||||
logger.warn('Telegram RSS is disabled due to the lack of token, api key or relevant config in config.js.');
|
||||
}
|
||||
router.get('/telegram/stickerpack/:name', require('./routes/telegram/stickerpack'));
|
||||
|
||||
// readhub
|
||||
router.get('/readhub/category/:category', require('./routes/readhub/category'));
|
||||
|
||||
// GitHub
|
||||
if (config.github && config.github.access_token) {
|
||||
router.get('/github/repos/:user', require('./routes/github/repos'));
|
||||
} else {
|
||||
logger.warn('GitHub Repos RSS is disabled due to the lack of token, api key or relevant config in config.js.');
|
||||
}
|
||||
router.get('/github/repos/:user', require('./routes/github/repos'));
|
||||
router.get('/github/trending/:since/:language?', require('./routes/github/trending'));
|
||||
router.get('/github/issue/:user/:repo', require('./routes/github/issue'));
|
||||
router.get('/github/pull/:user/:repo', require('./routes/github/pulls'));
|
||||
|
||||
@@ -2,6 +2,9 @@ const got = require('@/utils/got');
|
||||
const config = require('@/config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
if (!config.disqus || !config.disqus.api_key) {
|
||||
throw 'Disqus RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#%E9%83%A8%E5%88%86-rss-%E6%A8%A1%E5%9D%97%E9%85%8D%E7%BD%AE">relevant config</a>';
|
||||
}
|
||||
const forum = ctx.params.forum;
|
||||
|
||||
const response = await got({
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const got = require('@/utils/got');
|
||||
const config = require('@/config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const user = ctx.params.user;
|
||||
@@ -10,6 +11,9 @@ module.exports = async (ctx) => {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url,
|
||||
params: {
|
||||
access_token: config.github && config.github.access_token,
|
||||
},
|
||||
});
|
||||
const data = response.data;
|
||||
|
||||
|
||||
@@ -9,16 +9,12 @@ module.exports = async (ctx) => {
|
||||
|
||||
const fileUrl = `https://github.com/${user}/${repo}/commits/${branch}/${filepath}`;
|
||||
|
||||
const reqParams = {
|
||||
sha: branch,
|
||||
path: filepath,
|
||||
};
|
||||
if (config.github.access_token) {
|
||||
reqParams.access_token = config.github.access_token;
|
||||
}
|
||||
|
||||
const res = await got.get(`https://api.github.com/repos/${user}/${repo}/commits`, {
|
||||
params: reqParams,
|
||||
params: {
|
||||
sha: branch,
|
||||
path: filepath,
|
||||
access_token: config.github && config.github.access_token,
|
||||
},
|
||||
});
|
||||
const list = res.data;
|
||||
const count = [];
|
||||
|
||||
@@ -2,6 +2,9 @@ const got = require('@/utils/got');
|
||||
const config = require('@/config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
if (!config.github || !config.github.access_token) {
|
||||
throw 'GitHub follower RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#%E9%83%A8%E5%88%86-rss-%E6%A8%A1%E5%9D%97%E9%85%8D%E7%BD%AE">relevant config</a>';
|
||||
}
|
||||
const user = ctx.params.user;
|
||||
|
||||
const host = `https://github.com/${user}`;
|
||||
|
||||
@@ -16,7 +16,7 @@ module.exports = async (ctx) => {
|
||||
url,
|
||||
params: {
|
||||
sort: 'created',
|
||||
access_token: config.github.access_token,
|
||||
access_token: config.github && config.github.access_token,
|
||||
},
|
||||
});
|
||||
const data = response.data;
|
||||
|
||||
@@ -16,7 +16,7 @@ module.exports = async (ctx) => {
|
||||
url,
|
||||
params: {
|
||||
sort: 'created',
|
||||
access_token: config.github.access_token,
|
||||
access_token: config.github && config.github.access_token,
|
||||
},
|
||||
});
|
||||
const data = response.data;
|
||||
|
||||
@@ -9,7 +9,7 @@ module.exports = async (ctx) => {
|
||||
url: `https://api.github.com/users/${user}/repos`,
|
||||
params: {
|
||||
sort: 'created',
|
||||
access_token: config.github.access_token,
|
||||
access_token: config.github && config.github.access_token,
|
||||
},
|
||||
});
|
||||
const data = response.data;
|
||||
|
||||
@@ -2,6 +2,9 @@ const got = require('@/utils/got');
|
||||
const config = require('@/config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
if (!config.github || !config.github.access_token) {
|
||||
throw 'GitHub star RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#%E9%83%A8%E5%88%86-rss-%E6%A8%A1%E5%9D%97%E9%85%8D%E7%BD%AE">relevant config</a>';
|
||||
}
|
||||
const user = ctx.params.user;
|
||||
const repo = ctx.params.repo;
|
||||
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
const getToken = require('./token');
|
||||
const getBookmarks = require('./api/getBookmarks');
|
||||
const getUserDetail = require('./api/getUserDetail');
|
||||
const config = require('@/config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
if (!config.pixiv || !config.pixiv.client_id || !config.pixiv.client_secret || !config.pixiv.username || !config.pixiv.password) {
|
||||
throw 'pixiv RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#%E9%83%A8%E5%88%86-rss-%E6%A8%A1%E5%9D%97%E9%85%8D%E7%BD%AE">relevant config</a>';
|
||||
}
|
||||
|
||||
const id = ctx.params.id;
|
||||
|
||||
if (!getToken()) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const getToken = require('./token');
|
||||
const getRanking = require('./api/getRanking');
|
||||
const config = require('@/config');
|
||||
|
||||
const titles = {
|
||||
day: 'pixiv 日排行',
|
||||
@@ -32,6 +33,10 @@ const links = {
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
if (!config.pixiv || !config.pixiv.client_id || !config.pixiv.client_secret || !config.pixiv.username || !config.pixiv.password) {
|
||||
throw 'pixiv RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#%E9%83%A8%E5%88%86-rss-%E6%A8%A1%E5%9D%97%E9%85%8D%E7%BD%AE">relevant config</a>';
|
||||
}
|
||||
|
||||
const mode = ctx.params.mode;
|
||||
const date = ctx.params.date ? new Date(ctx.params.date) : new Date();
|
||||
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
const getToken = require('./token');
|
||||
const searchPopularIllust = require('./api/searchPopularIllust');
|
||||
const searchIllust = require('./api/searchIllust');
|
||||
const config = require('@/config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
if (!config.pixiv || !config.pixiv.client_id || !config.pixiv.client_secret || !config.pixiv.username || !config.pixiv.password) {
|
||||
throw 'pixiv RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#%E9%83%A8%E5%88%86-rss-%E6%A8%A1%E5%9D%97%E9%85%8D%E7%BD%AE">relevant config</a>';
|
||||
}
|
||||
|
||||
const keyword = ctx.params.keyword;
|
||||
const order = ctx.params.order || 'date';
|
||||
|
||||
|
||||
@@ -94,7 +94,9 @@ async function tokenLoop() {
|
||||
}
|
||||
}
|
||||
|
||||
tokenLoop();
|
||||
if (config.pixiv && config.pixiv.client_id && config.pixiv.client_secret && config.pixiv.username && config.pixiv.password) {
|
||||
tokenLoop();
|
||||
}
|
||||
|
||||
module.exports = function getToken() {
|
||||
return token;
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
const getToken = require('./token');
|
||||
const getIllusts = require('./api/getIllusts');
|
||||
const config = require('@/config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
if (!config.pixiv || !config.pixiv.client_id || !config.pixiv.client_secret || !config.pixiv.username || !config.pixiv.password) {
|
||||
throw 'pixiv RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#%E9%83%A8%E5%88%86-rss-%E6%A8%A1%E5%9D%97%E9%85%8D%E7%BD%AE">relevant config</a>';
|
||||
}
|
||||
|
||||
const id = ctx.params.id;
|
||||
|
||||
if (!getToken()) {
|
||||
|
||||
@@ -10,6 +10,9 @@ if (config.imgur && config.imgur.clientId) {
|
||||
}
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
if (!config.telegram || !config.telegram.token || !config.imgur || !config.imgur.clientId) {
|
||||
throw 'Telegram Sticker Pack RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#%E9%83%A8%E5%88%86-rss-%E6%A8%A1%E5%9D%97%E9%85%8D%E7%BD%AE">relevant config</a>';
|
||||
}
|
||||
const name = ctx.params.name;
|
||||
const cacheDays = 30;
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
const utils = require('./utils');
|
||||
const config = require('@/config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
if (!config.twitter || !config.twitter.consumer_key || !config.twitter.consumer_secret) {
|
||||
throw 'Twitter RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#%E9%83%A8%E5%88%86-rss-%E6%A8%A1%E5%9D%97%E9%85%8D%E7%BD%AE">relevant config</a>';
|
||||
}
|
||||
const id = ctx.params.id;
|
||||
const result = await utils.getTwit().get('favorites/list', {
|
||||
screen_name: id,
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
const utils = require('./utils');
|
||||
const config = require('@/config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
if (!config.twitter || !config.twitter.consumer_key || !config.twitter.consumer_secret) {
|
||||
throw 'Twitter RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#%E9%83%A8%E5%88%86-rss-%E6%A8%A1%E5%9D%97%E9%85%8D%E7%BD%AE">relevant config</a>';
|
||||
}
|
||||
const { id, name } = ctx.params;
|
||||
const result = await utils.getTwit().get('lists/statuses', {
|
||||
owner_screen_name: id,
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
const utils = require('./utils');
|
||||
const config = require('@/config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
if (!config.twitter || !config.twitter.consumer_key || !config.twitter.consumer_secret) {
|
||||
throw 'Twitter RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#%E9%83%A8%E5%88%86-rss-%E6%A8%A1%E5%9D%97%E9%85%8D%E7%BD%AE">relevant config</a>';
|
||||
}
|
||||
|
||||
const id = ctx.params.id;
|
||||
const result = await utils.getTwit().get('statuses/user_timeline', {
|
||||
screen_name: id,
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
const utils = require('./utils');
|
||||
const config = require('@/config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
if (!config.youtube || !config.youtube.key) {
|
||||
throw 'Youtube RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#%E9%83%A8%E5%88%86-rss-%E6%A8%A1%E5%9D%97%E9%85%8D%E7%BD%AE">relevant config</a>';
|
||||
}
|
||||
const id = ctx.params.id;
|
||||
const embed = !ctx.params.embed;
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
const utils = require('./utils');
|
||||
const config = require('@/config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
if (!config.youtube || !config.youtube.key) {
|
||||
throw 'Youtube RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#%E9%83%A8%E5%88%86-rss-%E6%A8%A1%E5%9D%97%E9%85%8D%E7%BD%AE">relevant config</a>';
|
||||
}
|
||||
const id = ctx.params.id;
|
||||
const embed = !ctx.params.embed;
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
const utils = require('./utils');
|
||||
const config = require('@/config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
if (!config.youtube || !config.youtube.key) {
|
||||
throw 'Youtube RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#%E9%83%A8%E5%88%86-rss-%E6%A8%A1%E5%9D%97%E9%85%8D%E7%BD%AE">relevant config</a>';
|
||||
}
|
||||
const username = ctx.params.username;
|
||||
const embed = !ctx.params.embed;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user