Skip to content

Commit

Permalink
perf: Wrap to promise all when create files while creating plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
aXenDeveloper committed Oct 23, 2024
1 parent 2f004e9 commit 812664f
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 52 deletions.
54 changes: 29 additions & 25 deletions packages/backend/src/core/admin/plugins/create/create.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,38 +86,42 @@ export class CreateAdminPluginsService {
// Verify files and folders to check if they exist
this.verifyFilesService.verifyFiles({ code });

// Create basic files
await this.createFilesService.createFiles({
author,
author_url,
code,
description,
name,
support_url,
allow_default: true,
nav: [],
version: '0.0.1',
version_code: 1,
});
const [data] = await Promise.all([
// Insert into database
this.databaseService.db
.insert(core_plugins)
.values({
code,
description,
name,
support_url,
author,
author_url,
})
.returning(),

const [data] = await this.databaseService.db
.insert(core_plugins)
.values({
// Create basic files
this.createFilesService.createFiles({
author,
author_url,
code,
description,
name,
support_url,
author,
author_url,
})
.returning();
allow_default: true,
nav: [],
version: '0.0.1',
version_code: 1,
}),

// Create i18n files
await this.createLanguageFiles({ code, name });
// Create i18n files
this.createLanguageFiles({ code, name }),

// Modifying / Create files
await this.changeFilesService.changeFiles({ code, action: 'add' });
// Modifying / Create files
this.changeFilesService.changeFiles({ code, action: 'add' }),
this.changeFilesService.setServerToRestartConfig(),
]);

return data;
return data[0];
}
}
105 changes: 78 additions & 27 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 812664f

Please sign in to comment.