Skip to content

Commit

Permalink
fix(server): add generic for function createGetModulesMethod
Browse files Browse the repository at this point in the history
  • Loading branch information
Огриско Егор Александрович committed Aug 27, 2024
1 parent 20c87ea commit c9224a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import { getAppManifest, readAssetsManifest } from '../read-assets-manifest';

import { ModulesConfig } from './types';

export function createGetModulesMethod<FrameworkParams extends unknown[] = []>(
modules: ModulesConfig<FrameworkParams>,
export function createGetModulesMethod<FrameworkParams extends unknown[] = [], GetResourcesParams = void>(
modules: ModulesConfig<FrameworkParams, GetResourcesParams>,
) {
const assets: Record<string, Awaited<ReturnType<typeof readAssetsManifest>>> = {};

return {
method: 'POST',
path: '/api/getModuleResources',
handler: async (
getResourcesRequest: GetResourcesRequest,
getResourcesRequest: GetResourcesRequest<GetResourcesParams>,
...params: FrameworkParams
): Promise<ModuleResources> => {
const appManifest = await getAppManifest();
Expand Down
8 changes: 4 additions & 4 deletions packages/arui-scripts-server/src/modules/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import type {
MountMode,
} from '@alfalab/scripts-modules';

export type ModuleDescriptor<FrameworkParams extends unknown[] = []> = {
export type ModuleDescriptor<FrameworkParams extends unknown[] = [], GetResourcesParams = void> = {
mountMode: MountMode;
version?: string;
getModuleState: (
getResourcesRequest: GetResourcesRequest,
getResourcesRequest: GetResourcesRequest<GetResourcesParams>,
...params: FrameworkParams
) => Promise<GetModuleStateResult>;
};

export type ModulesConfig<FrameworkParams extends unknown[] = []> = {
[moduleId: string]: ModuleDescriptor<FrameworkParams>;
export type ModulesConfig<FrameworkParams extends unknown[] = [], GetResourcesParams = void> = {
[moduleId: string]: ModuleDescriptor<FrameworkParams, GetResourcesParams>;
};

0 comments on commit c9224a9

Please sign in to comment.