fix: update block controller

This commit is contained in:
abdou6666 2025-03-24 11:59:18 +01:00
parent 408d50a5d3
commit 992ae79fc3

View File

@ -93,7 +93,7 @@ export class BlockController extends BaseController<
* @returns An array containing the settings of the specified plugin. * @returns An array containing the settings of the specified plugin.
*/ */
@Get('customBlocks/settings') @Get('customBlocks/settings')
findSettings(@Query('plugin') pluginName: PluginName) { async findSettings(@Query('plugin') pluginName: PluginName) {
try { try {
if (!pluginName) { if (!pluginName) {
throw new BadRequestException( throw new BadRequestException(
@ -110,7 +110,7 @@ export class BlockController extends BaseController<
throw new NotFoundException('Plugin Not Found'); throw new NotFoundException('Plugin Not Found');
} }
return plugin.getDefaultSettings(); return await plugin.getDefaultSettings();
} catch (e) { } catch (e) {
this.logger.error('Unable to fetch plugin settings', e); this.logger.error('Unable to fetch plugin settings', e);
throw e; throw e;
@ -123,7 +123,7 @@ export class BlockController extends BaseController<
* @returns An array containing available custom blocks. * @returns An array containing available custom blocks.
*/ */
@Get('customBlocks') @Get('customBlocks')
findAll() { async findAll() {
try { try {
const plugins = this.pluginsService const plugins = this.pluginsService
.getAllByType(PluginType.block) .getAllByType(PluginType.block)
@ -150,7 +150,7 @@ export class BlockController extends BaseController<
typeof p.effects === 'object' ? Object.keys(p.effects) : [], typeof p.effects === 'object' ? Object.keys(p.effects) : [],
}; };
}); });
return plugins; return await Promise.all(plugins);
} catch (e) { } catch (e) {
this.logger.error(e); this.logger.error(e);
throw e; throw e;