feat: v3 migration - 3/n
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
import got from '@/utils/got';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
const appFeedUrl = 'https://raw.githubusercontent.com/Squidly271/AppFeed/master/applicationFeed.json';
|
||||
const defaultLimit = 20;
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { data } = await got(appFeedUrl);
|
||||
const limit = ctx.query.limit ? Number.parseInt(ctx.query.limit) : defaultLimit;
|
||||
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : defaultLimit;
|
||||
|
||||
let appList = data.applist;
|
||||
appList = appList.map((app) => {
|
||||
@@ -19,7 +19,7 @@ module.exports = async (ctx) => {
|
||||
appList.sort((a, b) => b._pubDate - a._pubDate);
|
||||
const returnedAppList = appList.slice(0, limit);
|
||||
|
||||
ctx.state.data = {
|
||||
ctx.set('data', {
|
||||
title: 'Unraid Community Apps',
|
||||
link: 'https://unraid.net/community/apps',
|
||||
image: 'https://craftassets.unraid.net/static/favicon/favicon.ico?v=1.0',
|
||||
@@ -31,5 +31,5 @@ module.exports = async (ctx) => {
|
||||
category: app.CategoryList,
|
||||
upvotes: app.stars,
|
||||
})),
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user