-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Configuration: audit, clean, extend & improve #7488
Comments
refs #7488 If you want to set properties for our configuration values using environment variables on the command line, Linux and MacOS return an invalid identifier error. ``` $ export database:connection:host=127.0.0.1 -bash: export: `database:connection:host=127.0.0.1': not a valid identifier ``` According to the nconf documentation a custom separator can be set. The docs suggest `'__'` which this PR adds.
refs TryGhost#7488 - if multiple projects use nconf, they all operate on the same cached nconf instance - that can cause trouble
refs #7488 - if multiple projects use nconf, they all operate on the same cached nconf instance - that can cause trouble
I just added a todo here to revist all of our checks against |
Can you show an example?maybe pseudo code? |
Instead of doing |
Agree, if a unit can be enabled or disabled per product definition, then it would makes sense 👍 |
refs TryGhost#7491, refs TryGhost#7488
closes #4172, closes #6948, refs #7491, refs #7488, refs #7542, refs #7484 * 🎨 Co-locate all admin-related code in /admin - move all the admin related code from controllers, routes and helpers into a single location - add error handling middleware explicitly to adminApp - re-order blogApp middleware to ensure the shared middleware is mounted after the adminApp - TODO: rethink the structure of /admin, this should probably be an internal app * 💄 Group global middleware together - There are only a few pieces of middleware which are "global" - These are needed for the admin, blog and api - Everything else is only needed in one or two places * ✨ Introduce a separate blogApp - create a brand-new blogApp - mount all blog/theme only middleware etc onto blogApp - mount error handling on blogApp only * 🎨 Separate error handling for HTML & API JSON - split JSON and HTML error handling into separate functions - re-introduce a way to not output the stack for certain errors - add more tests around errors & an assertion framework for checking JSON Errors - TODO: better 404 handling for static assets Rationale: The API is very different to the blog/admin panel: - It is intended to only ever serve JSON, never HTML responses - It is intended to always serve JSON Meanwhile the blog and admin panel have no need for JSON errors, when an error happens on those pages, we should serve HTML pages which are nicely formatted with the error & using the correct template * 🐛 Fix checkSSL to work for subapps - in order to make this work on a sub app we need to use the pattern `req.originalUrl || req.url` * 🔥 Get rid of decide-is-admin (part 1/2) - delete decide-is-admin & tests - add two small functions to apiApp and adminApp to set res.isAdmin - mount checkSSL on all the apps - TODO: deduplicate the calls to checkSSL by making blogApp a subApp :D - PART 2/2: finish cleaning this up by removing it from where it's not needed and giving it a more specific name Rationale: Now that we have both an adminApp and an apiApp, we can temporarily replace this weird path-matching middleware with middleware that sets res.isAdmin for api & admin * 🎨 Wire up prettyURLs on all Apps - prettyURLs is needed for all requests - it cannot be global because it has to live after asset middleware, and before routing - this does not result in duplicate redirects, but does result in duplicate checks - TODO: resolve extra middleware in stack by making blogApp a sub app * ⏱ Add debug to API setup * 🎨 Rename blogApp -> parentApp in middleware * 🎨 Co-locate all blog-related code in /blog - Move all of the blogApp code from middleware/index.js to blog/app.js - Move routes/frontend.js to blog/routes.js - Remove the routes/index.js and routes folder, this is empty now! - @todo is blog the best name for this? 🤔 - @todo sort out the big hunk of asset-related mess - @todo also separate out the concept of theme from blog * 🎉 Replace middleware index with server/app.js - The final piece of the puzzle! 🎉 🎈 🎂 - We no longer have our horrendous middleware/index.js - Instead, we have a set of app.js files, which all use a familiar pattern * 💄 Error handling fixups
refs TryGhost#7488 If you want to set properties for our configuration values using environment variables on the command line, Linux and MacOS return an invalid identifier error. ``` $ export database:connection:host=127.0.0.1 -bash: export: `database:connection:host=127.0.0.1': not a valid identifier ``` According to the nconf documentation a custom separator can be set. The docs suggest `'__'` which this PR adds.
refs TryGhost#7488 - if multiple projects use nconf, they all operate on the same cached nconf instance - that can cause trouble
closes TryGhost#4172, closes TryGhost#6948, refs TryGhost#7491, refs TryGhost#7488, refs TryGhost#7542, refs TryGhost#7484 * 🎨 Co-locate all admin-related code in /admin - move all the admin related code from controllers, routes and helpers into a single location - add error handling middleware explicitly to adminApp - re-order blogApp middleware to ensure the shared middleware is mounted after the adminApp - TODO: rethink the structure of /admin, this should probably be an internal app * 💄 Group global middleware together - There are only a few pieces of middleware which are "global" - These are needed for the admin, blog and api - Everything else is only needed in one or two places * ✨ Introduce a separate blogApp - create a brand-new blogApp - mount all blog/theme only middleware etc onto blogApp - mount error handling on blogApp only * 🎨 Separate error handling for HTML & API JSON - split JSON and HTML error handling into separate functions - re-introduce a way to not output the stack for certain errors - add more tests around errors & an assertion framework for checking JSON Errors - TODO: better 404 handling for static assets Rationale: The API is very different to the blog/admin panel: - It is intended to only ever serve JSON, never HTML responses - It is intended to always serve JSON Meanwhile the blog and admin panel have no need for JSON errors, when an error happens on those pages, we should serve HTML pages which are nicely formatted with the error & using the correct template * 🐛 Fix checkSSL to work for subapps - in order to make this work on a sub app we need to use the pattern `req.originalUrl || req.url` * 🔥 Get rid of decide-is-admin (part 1/2) - delete decide-is-admin & tests - add two small functions to apiApp and adminApp to set res.isAdmin - mount checkSSL on all the apps - TODO: deduplicate the calls to checkSSL by making blogApp a subApp :D - PART 2/2: finish cleaning this up by removing it from where it's not needed and giving it a more specific name Rationale: Now that we have both an adminApp and an apiApp, we can temporarily replace this weird path-matching middleware with middleware that sets res.isAdmin for api & admin * 🎨 Wire up prettyURLs on all Apps - prettyURLs is needed for all requests - it cannot be global because it has to live after asset middleware, and before routing - this does not result in duplicate redirects, but does result in duplicate checks - TODO: resolve extra middleware in stack by making blogApp a sub app * ⏱ Add debug to API setup * 🎨 Rename blogApp -> parentApp in middleware * 🎨 Co-locate all blog-related code in /blog - Move all of the blogApp code from middleware/index.js to blog/app.js - Move routes/frontend.js to blog/routes.js - Remove the routes/index.js and routes folder, this is empty now! - @todo is blog the best name for this? 🤔 - @todo sort out the big hunk of asset-related mess - @todo also separate out the concept of theme from blog * 🎉 Replace middleware index with server/app.js - The final piece of the puzzle! 🎉 🎈 🎂 - We no longer have our horrendous middleware/index.js - Instead, we have a set of app.js files, which all use a familiar pattern * 💄 Error handling fixups
refs TryGhost#7488 If you want to set properties for our configuration values using environment variables on the command line, Linux and MacOS return an invalid identifier error. ``` $ export database:connection:host=127.0.0.1 -bash: export: `database:connection:host=127.0.0.1': not a valid identifier ``` According to the nconf documentation a custom separator can be set. The docs suggest `'__'` which this PR adds.
refs TryGhost#7488 - if multiple projects use nconf, they all operate on the same cached nconf instance - that can cause trouble
closes TryGhost#4172, closes TryGhost#6948, refs TryGhost#7491, refs TryGhost#7488, refs TryGhost#7542, refs TryGhost#7484 * 🎨 Co-locate all admin-related code in /admin - move all the admin related code from controllers, routes and helpers into a single location - add error handling middleware explicitly to adminApp - re-order blogApp middleware to ensure the shared middleware is mounted after the adminApp - TODO: rethink the structure of /admin, this should probably be an internal app * 💄 Group global middleware together - There are only a few pieces of middleware which are "global" - These are needed for the admin, blog and api - Everything else is only needed in one or two places * ✨ Introduce a separate blogApp - create a brand-new blogApp - mount all blog/theme only middleware etc onto blogApp - mount error handling on blogApp only * 🎨 Separate error handling for HTML & API JSON - split JSON and HTML error handling into separate functions - re-introduce a way to not output the stack for certain errors - add more tests around errors & an assertion framework for checking JSON Errors - TODO: better 404 handling for static assets Rationale: The API is very different to the blog/admin panel: - It is intended to only ever serve JSON, never HTML responses - It is intended to always serve JSON Meanwhile the blog and admin panel have no need for JSON errors, when an error happens on those pages, we should serve HTML pages which are nicely formatted with the error & using the correct template * 🐛 Fix checkSSL to work for subapps - in order to make this work on a sub app we need to use the pattern `req.originalUrl || req.url` * 🔥 Get rid of decide-is-admin (part 1/2) - delete decide-is-admin & tests - add two small functions to apiApp and adminApp to set res.isAdmin - mount checkSSL on all the apps - TODO: deduplicate the calls to checkSSL by making blogApp a subApp :D - PART 2/2: finish cleaning this up by removing it from where it's not needed and giving it a more specific name Rationale: Now that we have both an adminApp and an apiApp, we can temporarily replace this weird path-matching middleware with middleware that sets res.isAdmin for api & admin * 🎨 Wire up prettyURLs on all Apps - prettyURLs is needed for all requests - it cannot be global because it has to live after asset middleware, and before routing - this does not result in duplicate redirects, but does result in duplicate checks - TODO: resolve extra middleware in stack by making blogApp a sub app * ⏱ Add debug to API setup * 🎨 Rename blogApp -> parentApp in middleware * 🎨 Co-locate all blog-related code in /blog - Move all of the blogApp code from middleware/index.js to blog/app.js - Move routes/frontend.js to blog/routes.js - Remove the routes/index.js and routes folder, this is empty now! - @todo is blog the best name for this? 🤔 - @todo sort out the big hunk of asset-related mess - @todo also separate out the concept of theme from blog * 🎉 Replace middleware index with server/app.js - The final piece of the puzzle! 🎉 🎈 🎂 - We no longer have our horrendous middleware/index.js - Instead, we have a set of app.js files, which all use a familiar pattern * 💄 Error handling fixups
If a custom config file can't be parsed, then Ghost won't be able to print a nice error, because logging depends on config! If config can't be load, logging can't be initialised. Even if we force logging to initialise with a default config, we would have to add try/catch statements to the logging adapter and to the bootstrapping of Ghost, because config loads synchronously! Or we could load config asynchronous. But all of this because we can't parse a JSON file? I suggest that, as we have a config validation issue, which is committed as must have for |
* 🐛 delete client if auth url has changed no issue * 🎨 update default auth config refs #7488
Couple of notes / thoughts as I'm moving around:
|
refs TryGhost#7488, TryGhost#7491 - At the moment, we use the same asset helper function for both admin and theme - Both functions are (rightly or wrongly) a wrapper around meta.getAssetUrl() - The usecases in these contexts are v. different: - asset for the admin is used only in the generated index.html file - ghost="true" is always true in this case, except for the favicon which is ALREADY a separate case - minifyInProduction is only used to the admin panel, not documented or supposed to be used for themes - For themes, the helper doesn't take any arguments, it should just call to getAssetUrl() If we do want to introduce some sort of .min path adjuster we should give it a better name! - For the admin panel, minifyInProduction means exactly what it says - minify if env === production, it makes no sense IMO to move this to config because we control it and also plus "minifyAssets" made it sound like we had an asset pipeline when all this did was change the output from .js to .min.js or .css to .min.css
@ErisDS How about creating smaller config issues, assign to the milestone if they are required for the beta and close this one? |
refs TryGhost#7488 - This has always been documented as top-level "compress", and yet the code references server.compress - Should be top level, I think?
refs #7488 - This has always been documented as top-level "compress", and yet the code references server.compress - Should be top level
I just went over the last tasks from the issue.
We are using the
Was already removed and replaced by
yeah can do that in case we would like to add
done already, see 1b965fa and be5b584
We will keep that in mind.
Probably yes. I've tested a case a couple of days ago to change
Was partially done for theme and admin. I will also add it for the cache control.
Not sure what to reconsider here 🤔 This needs more context. |
refs TryGhost#7488 - simply rename the config usage - we might want to add `apps.external` later
refs TryGhost#7488 - cache control can be overridden if needed
refs #7488 - simply rename the config usage - we might want to add `apps.external` later
refs #7488 - cache control can be overridden if needed
closed via #8491 |
To clarify what I meant by this (sorry, I realise there is not anywhere near enough information), I was thinking about the fact that we have a huge block of "paths" in overrides.json, however: The admin path, Meanwhile with regard to the path for themes, that is derived from the ONLY path that is allowed to be overridden, because in defaults.json we have:
However,
Again, don't think it's urgent, just wanted to clarify because I saw this. Let me know if it makes sense now? |
👍 Thank you! I agree to the custom theme and image paths. We can add this later as a none breaking change and support both notations. You either specify a |
As the refactor of config is done, and we've had a chance to use it for a little while, it would be good to revisit it again before the end of alpha. There are a couple of outstanding todos from #6982 plus I'd like to look at what config options we provide. Do they make sense? Are there some things which should not be config? Some things which should be and aren't?
Things that definitely need review/audit:
- [ ] our use of paths in overrides.jsonneed's more context- [ ] revisit paths likeneed's more context/ghost/
and/ghost/api/<verison>
url
and related config options likeforceAdminSSL
(+ redirect option).compress
config differs (docs saycompress
implementation looks forserver.compress
).- [ ] catch the error thrown from nconf, and rethrow it in a prettyier, clearer, more Ghost-likefashion (see #7488 (comment)):Anyone who has something else they'd like reconsidered, please add a comment!
TODOs from #6982:
.file()
client
to theconfig.development.json
fileTODO's from #7692
Issue fixes
The text was updated successfully, but these errors were encountered: