mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-08 04:50:12 +02:00
add new api controller, rework and rename types
This commit is contained in:
@@ -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;
|
||||
};
|
||||
Reference in New Issue
Block a user