mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* add prefix to API resources * fix pw tests * refactor config * remove unnecessary prefixes in resource names * fixes * update screenshots
22 lines
623 B
TypeScript
22 lines
623 B
TypeScript
import type { ApiName, ApiResource } from './types';
|
|
|
|
import config from 'configs/app';
|
|
|
|
import type { ResourceName } from './resources';
|
|
import { RESOURCES } from './resources';
|
|
|
|
export default function getResourceParams(resourceFullName: ResourceName) {
|
|
const [ apiName, resourceName ] = resourceFullName.split(':') as [ ApiName, string ];
|
|
const apiConfig = config.apis[apiName];
|
|
|
|
if (!apiConfig) {
|
|
throw new Error(`API config for ${ apiName } not found`);
|
|
}
|
|
|
|
return {
|
|
api: apiConfig,
|
|
apiName,
|
|
resource: RESOURCES[apiName][resourceName as keyof typeof RESOURCES[ApiName]] as ApiResource,
|
|
};
|
|
}
|