add new api controller, rework and rename types

This commit is contained in:
jeffvli
2025-07-12 16:00:26 -07:00
parent 6c360c3c19
commit a7f21db563
14 changed files with 325 additions and 317 deletions
+27
View File
@@ -0,0 +1,27 @@
import { adapter as subsonicAdapter } from './subsonic/subsonic-controller';
import i18n from '/@/i18n/i18n';
import { ApiController } from '/@/shared/types/adapter/api-controller-types';
import { ServerType } from '/@/shared/types/domain/server-domain-types';
interface ApiControllerOptions {
type: ServerType;
}
const adapters = {
[ServerType.JELLYFIN]: {},
[ServerType.NAVIDROME]: {},
[ServerType.SUBSONIC]: subsonicAdapter,
} as Record<ServerType, ApiController>;
export const apiController = (options: ApiControllerOptions): ApiController => {
const { type } = options;
const adapter = adapters[type];
if (!adapter) {
throw new Error(i18n.t('error.apiRouteError', { postProcess: 'sentenceCase' }));
}
return adapter;
};