Files
RSSHub/lib/v2/twitter/api_fallback_common.js
Rongrong df5d3fc918 fix(route)(twitter): quote ignored in web API (#10361)
* fix(route)(twitter): quote ignored in web API

* refactor: migrate to v2

Signed-off-by: Rongrong <i@rong.moe>
2022-08-01 20:25:32 +08:00

18 lines
599 B
JavaScript

const config = require('@/config').value;
const logger = require('@/utils/logger');
const utils = require('./utils');
module.exports = async (ctx, devApiImpl, webApiImpl) => {
const { force_web_api } = utils.parseRouteParams(ctx.params.routeParams);
if (!force_web_api && config.twitter && config.twitter.consumer_key && config.twitter.consumer_secret) {
try {
await devApiImpl(ctx);
return;
} catch (e) {
logger.error(`Fallback to Twitter web API due to developer API error:\n${e.stack}`);
}
}
await webApiImpl(ctx);
};