mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-24 02:08:55 +08:00
feat: esm standard for routes
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import got from '@/utils/got';
|
||||
import { config } from '@/config';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
export default async (ctx) => {
|
||||
const user = ctx.req.param('user');
|
||||
const repo = ctx.req.param('repo');
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ const typeDict = {
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
export default async (ctx) => {
|
||||
const user = ctx.req.param('user');
|
||||
const repo = ctx.req.param('repo');
|
||||
const number = ctx.req.param('number') && isNaN(Number.parseInt(ctx.req.param('number'))) ? 1 : Number.parseInt(ctx.req.param('number'));
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import got from '@/utils/got';
|
||||
import { config } from '@/config';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
export default async (ctx) => {
|
||||
const { user, repo, order, anon } = ctx.req.param();
|
||||
|
||||
const host = `https://github.com/${user}/${repo}`;
|
||||
|
||||
@@ -2,7 +2,7 @@ import got from '@/utils/got';
|
||||
import { config } from '@/config';
|
||||
import queryString from 'query-string';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
export default async (ctx) => {
|
||||
const user = ctx.req.param('user');
|
||||
const repo = ctx.req.param('repo');
|
||||
const branch = ctx.req.param('branch');
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import got from '@/utils/got';
|
||||
import { config } from '@/config';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
export default async (ctx) => {
|
||||
if (!config.github || !config.github.access_token) {
|
||||
throw new Error('GitHub follower RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import got from '@/utils/got';
|
||||
import { config } from '@/config';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
export default async (ctx) => {
|
||||
const gistId = ctx.req.param('gistId');
|
||||
|
||||
const headers = { Accept: 'application/vnd.github.v3+json' };
|
||||
|
||||
@@ -7,7 +7,7 @@ const md = require('markdown-it')({
|
||||
import queryString from 'query-string';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
export default async (ctx) => {
|
||||
const user = ctx.req.param('user');
|
||||
const repo = ctx.req.param('repo');
|
||||
const state = ctx.req.param('state');
|
||||
|
||||
@@ -4,7 +4,7 @@ import { parseDate } from '@/utils/parse-date';
|
||||
const apiUrl = 'https://api.github.com';
|
||||
import { config } from '@/config';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
export default async (ctx) => {
|
||||
if (!config.github || !config.github.access_token) {
|
||||
throw new Error('GitHub trending RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ const md = require('markdown-it')({
|
||||
});
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
export default async (ctx) => {
|
||||
const user = ctx.req.param('user');
|
||||
const repo = ctx.req.param('repo');
|
||||
const state = ctx.req.param('state') ?? 'open';
|
||||
|
||||
@@ -5,7 +5,7 @@ import md5 from '@/utils/md5';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import { art } from '@/utils/render';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
export default async (ctx) => {
|
||||
const { user, repo, period } = ctx.req.param();
|
||||
|
||||
const periods = ['daily', 'halfweekly', 'weekly', 'monthly'];
|
||||
|
||||
@@ -2,7 +2,7 @@ import got from '@/utils/got';
|
||||
import { config } from '@/config';
|
||||
import queryString from 'query-string';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
export default async (ctx) => {
|
||||
const user = ctx.req.param('user');
|
||||
|
||||
const headers = {};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = function (router) {
|
||||
export default (router) => {
|
||||
router.get('/branches/:user/:repo', './branches');
|
||||
router.get('/comments/:user/:repo/:type/:number', './comments'); // deprecated
|
||||
router.get('/comments/:user/:repo/:number?', './comments');
|
||||
|
||||
@@ -4,7 +4,7 @@ const url = require('url');
|
||||
|
||||
const host = 'https://github.com';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
export default async (ctx) => {
|
||||
const query = ctx.req.param('query');
|
||||
let sort = ctx.req.param('sort') || 'bestmatch';
|
||||
const order = ctx.req.param('order') || 'desc';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import got from '@/utils/got';
|
||||
import { config } from '@/config';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
export default async (ctx) => {
|
||||
if (!config.github || !config.github.access_token) {
|
||||
throw new Error('GitHub star RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import got from '@/utils/got';
|
||||
import { config } from '@/config';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
export default async (ctx) => {
|
||||
if (!config.github || !config.github.access_token) {
|
||||
throw new Error('GitHub star RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { load } from 'cheerio';
|
||||
import got from '@/utils/got';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
export default async (ctx) => {
|
||||
const link = `https://github.com/topics/${ctx.req.param('name')}`;
|
||||
const { data, url } = await got(link, {
|
||||
searchParams: new URLSearchParams(ctx.req.param('qs')),
|
||||
|
||||
@@ -4,7 +4,7 @@ import { art } from '@/utils/render';
|
||||
import { load } from 'cheerio';
|
||||
import * as path from 'node:path';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
export default async (ctx) => {
|
||||
if (!config.github || !config.github.access_token) {
|
||||
throw new Error('GitHub trending RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#pei-zhi-bu-fen-rss-mo-kuai-pei-zhi">relevant config</a>');
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
const baseUrl = 'https://github.com';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
export default async (ctx) => {
|
||||
const { user, repo, page } = ctx.req.param();
|
||||
|
||||
const url = `${baseUrl}/${user}/${repo}/wiki${page ? `/${page}` : ''}/_history`;
|
||||
|
||||
Reference in New Issue
Block a user