Closed yihangho closed 1 year ago
Just doing require(path.join(args.dpath, 'config')
, leaving off the extension, would allow JS files that export a config object. Literally no other changes needed.
Any update on this?
Hi, check out v2 of the admin. In v2 the admin is simply an Express.js middleware. Also, a little bit down below I am explaining exactly about that case and the fact that only the settings.json
is required to be a file stored on your server, but then even that can now be manipulated before passing as an object to the middleware, even though I don't know how useful that would be. But for the rest of the config, in particular the config
and the users
key it is actually recommended to load that from an external storage since that contains your password for the database connection and for your admin users respectively.
Also have a look at the changelog for any potential breaking changes, all are pretty minor.
I'm not sure if this has been discussed/considered before. Currently, the configuration files (
config.json
,settings.json
,custom.json
, andusers.json
) have to be JSON files since they are hardcoded as such in the codebase.This has some limitations - the most important one being they are static. For example, it is quite common for us to configure the database credentials using environment variables. This will not be possible with JSON files. My current solution to this is to generate these JSON files right before starting express admin. (Think of this as running
generateJsonFile && admin config
.)I think this is suboptimal. My proposal here is to accept JS files in addition to JSON files.
Pros:
Opens up new possibilities for the kind of things that we can do with express-admin. For example, we can add functions to
settings.js
to allow arbitrary formatting of data or even dynamically generated data. For example:Cons:
If this is something that the maintainers are willing to consider, I'm happy to come up with a prototype to get things started. 😃