Strapi content-type builder lifecycle hooks - strapi

I'm new to Strapi, I'm wondering: there is a way to configure content-type builder lifecycle hooks?
From the official documentation I see different ways to have lifecycle hooks for the models, what I'm looking for, though, is a way to have callbacks on the edit, save or delete content-type actions in the content-type builder with a plugin.

Related

Safe template engine (allow user to edit) in spring MVC?

I am wondering if there is a way to disable method invocations in thymeleaf? We would like to give our users the ability to edit the templates in our application. We plan to use thymeleaf, but we do not want users to be able to call methods or access static fields or methods.
I found an old post Disabling static context and method invocation in Thymeleaf It was not possible in 2018, I am wondering if it is still the case in 2022?
If this cannot be disabled in thymeleaf, then are there any safe template engines available in spring?
Thanks

how to add micrometer tags to webClient in spring

So I am collecting a metric like this
http_client_requests_seconds_count{clientname="www.exmaple.com", uri="/users/somethihng/1233"}
from my spring application using micrometer and exposing it to prometheus.
Now i didnt configured any of these metric's label/tags, this is provided by default with webClient metrics. Now 10s of such http_client metrics from my appliction are being collected but I want to add some specific tags to a particular webClient call (FYI: I have a separate webClient instance for making this call).
How can I add tags to metrics which is being collected from this one webClient ?
I have come across WebFluxTagsProvider and RouterFunctionMetrics but couldnt find appropriate code examples.
Also, i know how to add global common tags, question is about adding tags for a specific webClient calls.
Would really appreciate the help. Also, if you ned clarity on the question please post a comment.
Try using MetricsWebClientCustomizer, it is provided when WebClient is build

File upload with SPQR Graphql

I'm using spring boot and spqr graphql library. I need to upload a file(s) via graphql. I don't know what object type to expect in the service and I'm assuming that this isn't even supported.
Has anyone tried this? Any advice?
Thanks.
(Assuming you're using SPQR Spring Starter)
Uploading/downloading binaries is currently inconvenient in SPQR, but not impossible. You'd need to override the provided controller with your own and decide how you want to receive the queries and binaries, and how you want to send the results and binaries back. To override the controller, just provide your own bean of GraphQLController type.
Your best bet is implementing the GraphQL multipart request spec which thanks to Spring shouldn't be too complicated.
Btw you can always get to the raw request by injecting #GraphQLRootContext DefaultGlobalContext<NativeWebRequest> request as a method argument. From there you can obtain input and output streams.
You can also wire in a custom ArgumentInjector that can inject something more precise if you want.
In the near future, the starter will support the GraphQL multipart request spec out of the box.
If you're not using the starter, the situation is similar in that you're kind of on your own with implementing the transport for binaries and queries.
But, with all that said, it is generally a best practice to handle dealing with binaries outside of GraphQL completely (only send download URLs and such using GraphQL), so I highly recommend that approach if possible. The reason is that requiring optional specs breaks out-of-the-box compatibility with most clients.

Spring Data Rest modify Repository method URI

This may be a bit of a rudimentary question, but I have a repository where I can do a find by username as follows:
....../items/search/byUsername/?username=myusername
However, this is generally inconsistent with how AngularJS Resources treat queries. Is there a way to instead make the request URI for the same thing to be
....../items/?username=myusername
Or does that functionality not exist with spring data rest? custom methods can be made in the angular resource but it is tedious to do that for every possible search category
If Angular (read: a client library) defines what URI's have to look like, then it's fundamentally violating a core REST principle — which is that clients follow links and URI templates.
That said, if you're using Querydsl and let your repository extend QuerydslPredicateExecutor, collection resources can be filtered by using property expressions. See the reference documentation for details.
Another option would be to manually expose resources under the URIs expected and manually forward the calls. But again, I'd argue you're better off teaching Angular to behave like a proper REST client in the first place 🙃.

Custom HttpMessageConverter for Spring Data REST

I'm about to dig into the code to find out, but thought I'd ask since I can't find any documentation or references. Spring-data-rest seems to support only JSON (specifically HAL+json). I know I can probably overlay an mvc controller on top of the spring-data-rest endpoint (and autowire the RepositoryRestResource) but that creates a bit of a maintenance issue. I'd like to use content negotiation to allow CSV endpoints if a message converter is available for the domain type.
Do spring-data-rest endpoints work with custom view implementations?
edit (more specific): Do sprint-data-rest endpoints work with custom HttpMessageConverters when serializing responses?

Resources