* fix: allow multiple radar rules per route * fix: github folder * feat: add namespace to radar target * docs: fix types url
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { Route } from '@/types';
|
|
import got from '@/utils/got';
|
|
import { load } from 'cheerio';
|
|
|
|
export const route: Route = {
|
|
path: '/releases/:brand/:model',
|
|
radar: [
|
|
{
|
|
source: ['openwrt.org/toh/:band/:model'],
|
|
target: '/releases/:model',
|
|
},
|
|
],
|
|
name: 'Unknown',
|
|
maintainers: [],
|
|
handler,
|
|
};
|
|
|
|
async function handler(ctx) {
|
|
const brand = ctx.req.param('brand');
|
|
const model = ctx.req.param('model');
|
|
const url = `https://openwrt.org/toh/${brand}/${model}`;
|
|
const response = await got(url);
|
|
const $ = load(response.data);
|
|
const table = $('#installation').next();
|
|
|
|
return {
|
|
title: $('h1').text() + ' - OpenWrt Releases',
|
|
link: url,
|
|
description: $('.dw-content div.level1').text(),
|
|
language: 'en-US',
|
|
item: [
|
|
{
|
|
title: table.find('.supported_current_rel').text(),
|
|
link: url,
|
|
description: `Firmware OpenWrt Install: ${table.find('.firmware_openwrt_install_url').html()}<br><br>Firmware OpenWrt Upgrade: ${$('.firmware_openwrt_upgrade_url').html()}'`,
|
|
},
|
|
],
|
|
};
|
|
}
|