🎨 Rename "services" to "apps" in entire project

This commit is contained in:
Manuel Ruwe
2022-12-18 22:27:01 +01:00
parent 1e0a90f2ac
commit 661c05bc50
69 changed files with 661 additions and 495 deletions

View File

@@ -8,24 +8,24 @@ async function Get(req: NextApiRequest, res: NextApiResponse) {
const configName = getCookie('config-name', { req });
const { config }: { config: Config } = getConfig(configName?.toString() ?? 'default').props;
const { query } = req.query;
const service = config.services.find(
(service) => service.type === 'Overseerr' || service.type === 'Jellyseerr'
const app = config.apps.find(
(app) => app.type === 'Overseerr' || app.type === 'Jellyseerr'
);
// If query is an empty string, return an empty array
if (query === '' || query === undefined) {
return res.status(200).json([]);
}
if (!service || !query || service === undefined || !service.apiKey) {
if (!app || !query || app === undefined || !app.apiKey) {
return res.status(400).json({
error: 'Wrong request',
});
}
const serviceUrl = new URL(service.url);
const appUrl = new URL(app.url);
const data = await axios
.get(`${serviceUrl.origin}/api/v1/search?query=${query}`, {
.get(`${appUrl.origin}/api/v1/search?query=${query}`, {
headers: {
// Set X-Api-Key to the value of the API key
'X-Api-Key': service.apiKey,
'X-Api-Key': app.apiKey,
},
})
.then((res) => res.data);