Skip to content

Commit

Permalink
feat: v3 migration - 16/n
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Feb 29, 2024
1 parent 300d450 commit 9d980d7
Show file tree
Hide file tree
Showing 18 changed files with 49 additions and 41 deletions.
10 changes: 10 additions & 0 deletions lib/v2/aqara/region.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = (ctx) => {
const types = {
news: 'press-release',
blog: 'article',
};

const { region = 'en', type = 'news' } = ctx.req.param();
const redirectTo = `/aqara/${region}/category/${types[type]}`;
ctx.redirect(redirectTo);
};
11 changes: 1 addition & 10 deletions lib/v2/aqara/router.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
module.exports = function (router) {
router.get('/cn/news', './news');
router.get('/community/:id?/:keyword?', './community');
router.get('/:region/:type?', (ctx) => {
const types = {
news: 'press-release',
blog: 'article',
};

const { region = 'en', type = 'news' } = ctx.req.param();
const redirectTo = `/aqara/${region}/category/${types[type]}`;
ctx.redirect(redirectTo);
});
router.get('/:region/:type?', './region');
router.get('*', './post');
};
4 changes: 2 additions & 2 deletions lib/v2/buaa/sme.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = async (ctx) => {
// 源链接
link: url,
// 源文章
item: await getItems(ctx, list),
item: await getItems(list),
});
};

Expand Down Expand Up @@ -46,7 +46,7 @@ async function getList(url) {
};
}

function getItems(ctx, list) {
function getItems(list) {
return Promise.all(
list.map((item) =>
cache.tryGet(item.link, async () => {
Expand Down
3 changes: 3 additions & 0 deletions lib/v2/dongqiudi/daily.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (ctx) => {
ctx.redirect('/dongqiudi/special/48');
};
2 changes: 1 addition & 1 deletion lib/v2/dongqiudi/router.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = (router) => {
router.get('/daily', (c) => c.redirect('/dongqiudi/special/48'));
router.get('/daily', './daily');
router.get('/player_news/:id', './player-news');
router.get('/result/:team', './result');
router.get('/special/:id', './special');
Expand Down
10 changes: 1 addition & 9 deletions lib/v2/getitfree/router.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
module.exports = (router) => {
router.get('/:filter*', (ctx) => {
const { filter } = ctx.req.param();

if (filter && !filter.includes('/') && !filter.includes(',')) {
ctx.redirect(`/getitfree/category/${filter}`);
} else {
return './'(ctx);
}
});
router.get('/:filter*', './index');
};
3 changes: 3 additions & 0 deletions lib/v2/hostmonit/cloudflareyesv6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (ctx) => {
ctx.redirect('/hostmonit/cloudflareyes/v6');
};
6 changes: 1 addition & 5 deletions lib/v2/hostmonit/router.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
const redirectToV6 = (ctx) => ctx.redirect('/hostmonit/cloudflareyes/v6');

module.exports = (router) => {
router.get('/cloudflareyes/:type?', './cloudflareyes');
router.get('/cloudflareyesv6', (ctx) => redirectToV6(ctx));
router.get('/CloudFlareYes/:type?', './cloudflareyes');
router.get('/CloudFlareYesv6', (ctx) => redirectToV6(ctx));
router.get('/cloudflareyesv6', './cloudflareyesv6');
};
6 changes: 6 additions & 0 deletions lib/v2/jiemian/list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = (ctx) => {
const id = ctx.req.param('id');

const redirectTo = `/jiemian${id ? `/lists/${id}` : ''}`;
ctx.redirect(redirectTo);
};
7 changes: 1 addition & 6 deletions lib/v2/jiemian/router.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
module.exports = function (router) {
router.get('/list/:id', (ctx) => {
const id = ctx.req.param('id');

const redirectTo = `/jiemian${id ? `/lists/${id}` : ''}`;
ctx.redirect(redirectTo);
});
router.get('/list/:id', './list');
router.get('/:category*', './lists');
};
5 changes: 5 additions & 0 deletions lib/v2/liulinblog/itnews.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = (ctx) => {
const { channel } = ctx.req.param();
const redirectTo = `/liulinblog/${channel}`;
ctx.redirect(redirectTo);
};
6 changes: 1 addition & 5 deletions lib/v2/liulinblog/router.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
module.exports = (router) => {
router.get('/itnews/:channel', (ctx) => {
const { channel } = ctx.req.param();
const redirectTo = `/liulinblog/${channel}`;
ctx.redirect(redirectTo);
});
router.get('/itnews/:channel', './itnews');
router.get('/:params*', './');
};
3 changes: 3 additions & 0 deletions lib/v2/nbd/daily.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (ctx) => {
ctx.redirect('/nbd/332');
};
2 changes: 1 addition & 1 deletion lib/v2/nbd/router.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = (router) => {
router.get('/daily', (c) => c.redirect('/nbd/332'));
router.get('/daily', './daily');
router.get('/:id?', './index');
};
3 changes: 3 additions & 0 deletions lib/v2/scmp/coronavirus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (ctx) => {
ctx.redirect('/scmp/topics/coronavirus-pandemic-all-stories');
};
2 changes: 1 addition & 1 deletion lib/v2/scmp/router.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = (router) => {
router.get('/coronavirus', (c) => c.redirect('/scmp/topics/coronavirus-pandemic-all-stories'));
router.get('/coronavirus', './coronavirus');
router.get('/:category_id', './index');
router.get('/topics/:topic', './topic');
};
5 changes: 5 additions & 0 deletions lib/v2/telegram/channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ const mediaTagDict = {
};

module.exports = async (ctx) => {
const useWeb = ctx.req.param('routeParams') || !(config.telegram.session && config.feature.mediaProxyKey);
if (!useWeb) {
return require('./tglib/channel')(ctx);
}

const username = ctx.req.param('username');
let routeParams = ctx.req.param('routeParams');
let showLinkPreview = true;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"build:all": "npm run build:radar && npm run build:maintainer",
"build:maintainer": "node scripts/workflow/build-maintainer.js",
"build:radar": "node scripts/workflow/build-radar.js",
"dev": "cross-env NODE_ENV=dev tsx watch lib/index.ts",
"dev": "cross-env NODE_ENV=dev tsx watch --no-cache lib/index.ts",
"format": "eslint --cache --fix \"**/*.{ts,js,yml}\" && node website/docs/.format/format.mjs && prettier \"**/*.{ts,js,json}\" --write",
"format:check": "eslint --cache \"**/*.{ts,js,yml}\" && prettier \"**/*.{ts,js,json}\" --check",
"format:staged": "lint-staged",
Expand Down

0 comments on commit 9d980d7

Please sign in to comment.