fix(36kr): add checks

This commit is contained in:
Tony
2024-12-05 22:19:39 +08:00
parent 9b684c2183
commit b35d47d685
+5
View File
@@ -4,6 +4,7 @@ import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { rootUrl, ProcessItem } from './utils';
import InvalidParameterError from '@/errors/types/invalid-parameter';
const categories = {
24: {
@@ -54,6 +55,10 @@ export const route: Route = {
async function handler(ctx) {
const category = ctx.req.param('category') ?? '24';
if (!categories[category]) {
throw new InvalidParameterError('This category does not exist. Please refer to the documentation for the correct usage.');
}
const currentUrl = category === '24' ? rootUrl : `${rootUrl}/hot-list/catalog`;
const response = await got({