Skip to content

Commit

Permalink
fix: getConfig types were incorrect
Browse files Browse the repository at this point in the history
  • Loading branch information
darlanalves committed May 7, 2024
1 parent f85755d commit 6780fb6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,9 @@ export function findFile(): string {
return '';
}

export async function getConfig<T extends Record<string, any>>(
moduleName: string,
defaults: T = null,
): Promise<ModuleConfiguration | T> {
export function getConfig<T extends ModuleConfiguration>(moduleName: string, defaults: T = null): T {
const filePath = join(process.cwd(), 'configuration', `${moduleName}.json`);
const config = readJson<ModuleConfiguration>(filePath);
const config = readJson<T>(filePath);

return Object.assign({}, defaults, config);
}
2 changes: 1 addition & 1 deletion src/http-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export class HttpServer {
};

private async runCommand(functionMap: any, command: string, functionName: string, params: any) {
const moduleConfig = await getConfig(command);
const moduleConfig = getConfig(command);
const optionFromFile = moduleConfig.commands?.[functionName] ?? {};
const mergedOptions = Object.assign({}, params, optionFromFile);

Expand Down

0 comments on commit 6780fb6

Please sign in to comment.