Open therealedsheenan opened 4 years ago
Lucky you! I'm unable to start it at all, too many bugs and nothing works from the readme. Literally nothing works.
Sounds good. Added to the todo list! @ruslanchek - Can you share some of the bugs you've encountered? It's about time we squashed a few 😅
It is indeed an important feature.
TL;DR: I'm pondering how to go about it but it's on the roadmap.
In the meanwhile, a workaround is to set environment variables (setting TYPEORM_URL
should be enough) while running the command. For example:
TYPEORM_URL=postgres://myuser:mypassword@myhost:5432/mydatabase npx nestjs-admin createAdminUser
At the moment, the nestjs-admin
script works if you use the standard conventions of TypeOrm (either top-level ormconfig.* or env vars, hardcoded config in TypeOrm.forRoot
can't be supported). And even then, we'll always use the default
database connection.
I am torn between several options (thinking out loud here):
--config
param, probably using ConnectionOptionsReader which isn't documented.createAdminUser
altogether, adding documentation on how to roll your own to fit your particular needs
Given that this is a script meant to be ran once per environment (to create an initial AdminUser, which can then create more through the admin interface), I'm not super happy about maintainance burden. That being said, it's one of the first interactions of the user with this library and I want it to be a good experience...
All in all, I'd probably go with the first option. I will post updates here once this is done (if anybody wants to work on this please do and announce it here)
Summary
It would be nice to have a support for a custom ormconfig.js when generating an admin user via CLI. Something like:
npx nestjs-admin createAdminUser --config=<CUSTOM_PATH>/config.js
.Current workaround
I needed to copy my custom
ormconfig.js
file to the root of the codebase and fire up the cli command from there. (npx nestjs-admin createAdminUser
).