Skip to content

Commit 91128fa

Browse files
committed
fix: create adminfuser only if no another users exist (this is for initial user only)
1 parent b3ec9be commit 91128fa

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

adminforth/commands/createApp/templates/index.ts.hbs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,14 @@ if (import.meta.url === `file://${process.argv[1]}`) {
6161

6262
const port = 3500;
6363

64-
await admin.bundleNow({ hotReload: process.env.NODE_ENV === 'development' });
65-
console.log('Bundling AdminForth SPA done.');
64+
admin.bundleNow({ hotReload: process.env.NODE_ENV === 'development' }).then(() => {
65+
console.log('Bundling AdminForth SPA done.');
66+
});
6667

67-
admin.express.serve(app)
68+
admin.express.serve(app);
6869

6970
admin.discoverDatabases().then(async () => {
70-
if (!await admin.resource('adminuser').get([Filters.EQ('email', 'adminforth')])) {
71+
if (await admin.resource('adminuser').count() === 0) {
7172
await admin.resource('adminuser').create({
7273
email: 'adminforth',
7374
password_hash: await AdminForth.Utils.generatePasswordHash('adminforth'),

adminforth/documentation/blog/2024-10-01-ai-blog/index.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,9 @@ if (import.meta.url === `file://${process.argv[1]}`) {
285285
app.use(express.json());
286286
const port = 3500;
287287

288-
await admin.bundleNow({ hotReload: process.env.NODE_ENV === 'development' });
289-
console.log('Bundling AdminForth SPA done.');
288+
admin.bundleNow({ hotReload: process.env.NODE_ENV === 'development' }).then(() => {
289+
console.log('Bundling AdminForth SPA done.');
290+
});
290291

291292
// api to server recent posts
292293
app.get('/api/posts', async (req, res) => {

adminforth/documentation/docs/tutorial/01-helloWorld.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,14 +299,15 @@ if (import.meta.url === `file://${process.argv[1]}`) {
299299
const port = 3500;
300300

301301
// needed to compile SPA. Call it here or from a build script e.g. in Docker build time to reduce downtime
302-
await admin.bundleNow({ hotReload: process.env.NODE_ENV === 'development' });
303-
console.log('Bundling AdminForth done. For faster serving consider calling bundleNow() from a build script.');
302+
admin.bundleNow({ hotReload: process.env.NODE_ENV === 'development' }).then(() => {
303+
console.log('Bundling AdminForth SPA done.');
304+
});
304305

305306
// serve after you added all api
306307
admin.express.serve(app)
307308

308309
admin.discoverDatabases().then(async () => {
309-
if (!await admin.resource('adminuser').get([Filters.EQ('email', 'adminforth')])) {
310+
if (await admin.resource('adminuser').count() === 0) {
310311
await admin.resource('adminuser').create({
311312
email: 'adminforth',
312313
passwordHash: await AdminForth.Utils.generatePasswordHash('adminforth'),

0 commit comments

Comments
 (0)