mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 15:35:55 +01:00
🐛 Add error catching for calender api route
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
"name": "Calendar",
|
||||
"description": "A calendar module for displaying upcoming releases. It interacts with the Sonarr and Radarr API.",
|
||||
"settings": {
|
||||
"title": "Settings for calendar integration",
|
||||
"sundayStart": {
|
||||
"label": "Start the week on Sunday"
|
||||
}
|
||||
|
||||
@@ -26,6 +26,5 @@
|
||||
}
|
||||
},
|
||||
"tip": "You can select the search bar with the shortcut ",
|
||||
"switchedSearchEngine": "Switched to searching with {{searchEngine}}",
|
||||
"configurationName": "Search engine configuration"
|
||||
"switchedSearchEngine": "Switched to searching with {{searchEngine}}"
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"title": "Search engine",
|
||||
"configurationName": "Search engine configuration",
|
||||
"tips": {
|
||||
"generalTip": "Use the prefixes !yt and !t in front of your query to search on YouTube or for a Torrent respectively.",
|
||||
"placeholderTip": "%s can be used as a placeholder for the query."
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import axios from 'axios';
|
||||
import Consola from 'consola';
|
||||
import { NextApiRequest, NextApiResponse } from 'next';
|
||||
import { getConfig } from '../../../tools/config/getConfig';
|
||||
import { AppIntegrationType } from '../../../types/app';
|
||||
@@ -44,6 +45,7 @@ async function Get(req: NextApiRequest, res: NextApiResponse) {
|
||||
(app) => app.integration && mediaAppIntegrationTypes.includes(app.integration.type)
|
||||
);
|
||||
|
||||
try {
|
||||
const medias = await Promise.all(
|
||||
await mediaApps.map(async (app) => {
|
||||
const integration = app.integration!;
|
||||
@@ -74,7 +76,6 @@ async function Get(req: NextApiRequest, res: NextApiResponse) {
|
||||
})
|
||||
);
|
||||
|
||||
// FIXME: I need an integration for each of them
|
||||
return res.status(200).json({
|
||||
tvShows: medias.filter((m) => m.type === 'sonarr').flatMap((m) => m.items),
|
||||
movies: medias.filter((m) => m.type === 'radarr').flatMap((m) => m.items),
|
||||
@@ -82,6 +83,17 @@ async function Get(req: NextApiRequest, res: NextApiResponse) {
|
||||
musics: medias.filter((m) => m.type === 'lidarr').flatMap((m) => m.items),
|
||||
totalCount: medias.reduce((p, c) => p + c.items.length, 0),
|
||||
});
|
||||
} catch (error) {
|
||||
Consola.error(`Error while requesting media from your app. Check your configuration. ${error}`);
|
||||
|
||||
return res.status(500).json({
|
||||
tvShows: [],
|
||||
movies: [],
|
||||
books: [],
|
||||
musics: [],
|
||||
totalCount: 0,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const IntegrationTypeEndpointMap = new Map<AppIntegrationType['type'], string>([
|
||||
|
||||
Reference in New Issue
Block a user