mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-10 15:28:47 +00:00
starting of widget refactoring
This commit is contained in:
parent
d6f6ea9dba
commit
562235f828
42 changed files with 337 additions and 301 deletions
|
@ -1,6 +1,7 @@
|
|||
import getServiceWidget from "utils/service-helpers";
|
||||
import { formatApiCall } from "utils/api-helpers";
|
||||
import { httpProxy } from "utils/http";
|
||||
import widgets from "widgets/widgets";
|
||||
|
||||
export default async function credentialedProxyHandler(req, res) {
|
||||
const { group, service, endpoint } = req.query;
|
||||
|
@ -8,8 +9,12 @@ export default async function credentialedProxyHandler(req, res) {
|
|||
if (group && service) {
|
||||
const widget = await getServiceWidget(group, service);
|
||||
|
||||
if (!widgets?.[widget.type]?.api) {
|
||||
return res.status(403).json({ error: "Service does not support API calls" });
|
||||
}
|
||||
|
||||
if (widget) {
|
||||
const url = new URL(formatApiCall(widget.type, { endpoint, ...widget }));
|
||||
const url = new URL(formatApiCall(widgets[widget.type].api, { endpoint, ...widget }));
|
||||
|
||||
const headers = {
|
||||
"Content-Type": "application/json",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue