feat: esm standard for routes

This commit is contained in:
DIYgod
2024-03-02 03:25:26 +08:00
parent f0e09ee9e0
commit df57bb5d50
3035 changed files with 3040 additions and 3038 deletions
+1 -1
View File
@@ -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');
+1 -1
View File
@@ -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 -1
View File
@@ -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}`;
+1 -1
View File
@@ -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 -1
View File
@@ -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>');
}
+1 -1
View File
@@ -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' };
+1 -1
View File
@@ -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');
+1 -1
View File
@@ -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>');
}
+1 -1
View File
@@ -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';
+1 -1
View File
@@ -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'];
+1 -1
View File
@@ -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 -1
View File
@@ -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');
+1 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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 -1
View File
@@ -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')),
+1 -1
View File
@@ -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>');
}
+1 -1
View File
@@ -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`;