New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarifications on how config.js is used #54
Comments
Both descriptions are essentially correct, though I agree the documentation should be improved. When the app is initialized, the wq config object is loaded from a static file, Once the user logs in, a second copy of the configuration is loaded dynamically. This version includes the base configuration plus any user-specific permissions. Thus, it is usually loaded via the wq.db's auth API, though is also available at Early on, wq.db actually included an "AMDRenderer", making it possible to load the dynamic configuration directly as a JavaScript file ( import wq from './wq.js';
import somePlugin from './somePlugin.js';
- import config from './data/config.js';
wq.use(somePlugin);
- wq.init(config);
+ async function init() {
+ const response = await fetch("/config.json"),
+ config = await response.json();
+ wq.init(config);
+ }
+
+ init(); As far as containerization, the first thing to note is that there are now two alternative templates, one of which does not require a JavaScript build system at all (see wq.app v1.3.0a1). My ultimate goal is to phase out deploy.sh in favor of just That said, power users will still appreciate the ability to customize a build with npm. For those users, you would indeed need to come up with a way to retrieve data/config.js from the django backend. Currently, @wq/cra-template won't even build until that file is in place. I would be open to discussing alternative solutions to make this work better, whether that means returning to a dynamic fetch or something else. FWIW, I personally have found the pre-built Not sure if that exact approach would work for you, but a Node+Python Docker container for building such a wheel could be pretty useful for my workflow. |
Thanks for the clarifications ! I like the idea of loading it dynamically only, as it reduces the complexity of the stack (static is really static :-) ). Wouldn't it be possible to push config.json with http2 to avoid initial round trip, yet still only have the dynamically generated config.json ? Or alternatively, inline it in index.html (obviously would only work if index.html is served dynamically) ?
Yes that would be a great improvement ! And not necessarily hard to achieve, maybe you just just put the whole front-end code under another django app (with just static files), so it gets automatically found, is easy to override if needed, and you get all django advantages with it (served with test server, cdn integration, etc.) In any case, I must say I'm a bit struggling with the current setup. Unfortunately I didn't manage to reuse the apache config as is (apache and mod_wsgi is quite a pain in a docker context compared to a better containerized solution with something like uwsgi + Caddy, which also fully takes care of https). But the apache config isn't easy to adapt (with semi-magic stuff like Do you have an est. timeframe for that ? |
Thanks for the feedback. I'd like to try and make config.js fully dynamic for the final 1.3 release, and also deprecate deploy.sh. A lot of the work is done already:
Here's what still needs to be done:
The main challenge with removing the static data/config.js file is that we'll still need to communicate where the WSGI service is (particularly if it's not at the root of the domain). One option would be to use relative paths to traverse out of the /static/app/js folder: As for the Apache config, I think |
The latest wq.db release supports a /config.js endpoint that can be used as a fully live configuration. The template still uses the generated data/config.js file by default, but it's easy enough to change the template to reference the live version. |
- simplify user-specific config JSON to only include permissions (see wq/wq#54) - include related_name in form config for ForeignKeys - detect SlugRelatedField when mapping _id columns - remove wq.db.default_settings - remove wq.db.patterns.identify - remove remaining Mustache template support - remove wq.db.rest.context_processors - remove wq.db.rest.auth.context_processors - remove url compatibility with include()
- simplify user-specific config JSON to only include permissions (see wq/wq#54) - include related_name in form config for ForeignKeys - detect SlugRelatedField when mapping _id columns - remove wq.db.default_settings - remove wq.db.patterns.identify - remove remaining Mustache template support - remove wq.db.rest.context_processors - remove wq.db.rest.auth.context_processors - remove url compatibility with include()
- simplify user-specific config JSON to only include permissions (see wq/wq#54) - include related_name in form config for ForeignKeys - detect SlugRelatedField when mapping _id columns - remove wq.db.default_settings - remove wq.db.patterns.identify - remove remaining Mustache template support - remove wq.db.rest.context_processors - remove wq.db.rest.auth.context_processors - remove url compatibility with include()
- simplify user-specific config JSON to only include permissions (see wq/wq#54) - include related_name in form config for ForeignKeys - detect SlugRelatedField when mapping _id columns - remove wq.db.default_settings - remove wq.db.patterns.identify - remove remaining Mustache template support - remove wq.db.rest.context_processors - remove wq.db.rest.auth.context_processors - remove url compatibility with include()
Hi !
As discussed in wq/wq-django-template#20, I'm interested in contributing a docker-compose setup for WQ.io, so it could be used easily cross-platform and would be easier to deploy.
There is however one thing that I don't understand and which looks a bit contradictory regarding
config.js
,It seems
config.js
is both :dump_config
management command (that is called fromdeploy.sh
) - which tends to indicate that this is needed at build time for the javascript app.I don't really see how these can both be true ?
This has an influence on how things can be containerized (ideally there would a nodejs image that can build completely independently from the django backend, but if the nodejs image requires config.js, it would get a little more complicated.)
Could you clarify how this works ?
The text was updated successfully, but these errors were encountered: