api/api-keys: add allowedServices to limit or extend access

it's useful for limiting access to services per key, or for overriding default list of enabled services with "all"
This commit is contained in:
wukko
2025-06-26 22:20:09 +06:00
parent d69100c68d
commit 3243564f77
4 changed files with 44 additions and 5 deletions

View File

@@ -199,7 +199,7 @@ export function normalizeURL(url) {
);
}
export function extract(url) {
export function extract(url, enabledServices = env.enabledServices) {
if (!(url instanceof URL)) {
url = new URL(url);
}
@@ -210,7 +210,7 @@ export function extract(url) {
return { error: "link.invalid" };
}
if (!env.enabledServices.has(host)) {
if (!enabledServices.has(host)) {
// show a different message when youtube is disabled on official instances
// as it only happens when shit hits the fan
if (new URL(env.apiURL).hostname.endsWith(".imput.net") && host === "youtube") {