- Issue created by @glynster
- 🇦🇹Austria fago Vienna
While I can see the use-case for needing this information, I don't think it makes sense to ship this information on every ce-api page response, since it would grow all the responses, while the information is usually only needed once. Thus, it seems to be better solved with a dedicated endpoint + a separate request to fetch it from nuxt. When done so, we shuold be able to leverage caching in nuxt such that the request is done only once in the server instance, and cached then.
On how to providing the information, I don't think there is a pre-existing API for it. So it makes sense to add it.
However, when adding it: The question becomes, what exactly shall we add? It seems very use-case specific what shall be added, there are definitely more config-settings that one might want to use in the frontend, for example a configured google analytics key.
Thus, I feel like we could build a solution for exposing any kind of config as "Site-info" and make it configurable, e.g. by specifying the keys you want:
system.site:name
system.site:slogan
system.site:mailand just output a data structure like
{ system.site : {
name: "..",
slogan: "..",
mail: "..."
}}and make the result a public API, e.g. at /lupus/site-info
I guess, that would make sense to provide as a new optional module, Lupus Decoupled Site Info ?
- First commit to issue fork.
- 🇸🇮Slovenia useernamee Ljubljana
I created the Lupus Decoupled Site Info module and added some initial configuration.
- 🇺🇸United States glynster
@useernamee great news. This will be very helpful. My only suggesting is the API route /api/lupus/site-info changes to /api/site-info seems more appropriate to me. Great job!
- 🇦🇹Austria fago Vienna
that seems pretty good already, thank you!
A few remarks:
- please check the MR comment
- I am not sure about the /api/lupus prefix also, what about just /api/site-info or /lupus-site-info ?
- We need some configuration form or README that documents how to use it
- We need some basic test coverage before merge! - 🇸🇮Slovenia useernamee Ljubljana
> I am not sure about the /api/lupus prefix also, what about just /api/site-info or /lupus-site-info ?
I went with the /api/site-info but this is also a limitation of the Rest resource which I picked for the task, since it would seem nicer to have a resource at the endpoint of /site-info, for uniformity.
- 🇦🇹Austria fago Vienna
thank you! that looks pretty good now. I've added one remark with this missing value though, please check MR review.
- 🇸🇮Slovenia useernamee Ljubljana
I removed the missing config option and added a watchdog error for that case instead:
{"system.site":{"name":"Drush Site-Install","slogan":"lupus.digital Publishing","mail":"admin@example.com","missing":null},"missing":{"missing":null}}
- 🇦🇹Austria fago Vienna
thank you! Reviewed it and edited a bit. Seems good to go now!
However, I did not test it yet. So it still needs a manual test before it's ready for merge!
- 🇦🇹Austria arthur_lorenz Vienna
Test failed, cache is not being invalidated after config changes.
To reproduce:
- Install
lupus_decoupled_site_info
module - Go to
/api/site-info
-> Info is correct - Go to
/admin/config/system/site-information
and update the slogan - Go to
/api/site-info
-> Info is outdated
- Install
- 🇸🇮Slovenia useernamee Ljubljana
Thank you @arthur. I wasn't paying attention to caching.
- Added cacheable dependencies to the response.
- Cache is tested. -
fago →
committed 619f2133 on 1.x authored by
useernamee →
Issue #3503890 by useernamee, glynster, arthur_lorenz: Allow exposing...
-
fago →
committed 619f2133 on 1.x authored by
useernamee →