also, why can’t I add a middleware on all datatype routes , I con only add them for each one. plus typescript typings tell me only core functionalities like findone, find, delete etc would be supported ?!
You can do middleware for all routes
That is what config/middlewares is for
I saw a guide, tried, and it didnt work. no examples in ther official doc i think
Only note you need to have is that before next() you have 0 infomation almost
Mind opening a issue on the docs for that then
since that should be documented for sure
sure, here we go: [Request]: Adding mdw to >all< routes of one content type · Issue #2044 · strapi/documentation · GitHub
about that werid controller behaviour: may be my strapi version or so ? could you maybe try recreating, <@333639824000942080> ? should take only 2 minutes, just check that ctx
in a controller after performing a find
or so
Will do after eating my dinner
And just confirmed this is a issue on the latest version
<@592795971675619329>
so what is happening makes sence since
<@211722558385553408> This seems intresting beavoir but should this be marked as like a bug or should this be documented as normal behavoir.
Let me check your findings tomorrow, got late already - assuming one doesn’t always add Middlewares etc to controller functions, it should show correct data in the controller already. Or to summarize: ctx should always reflect the state of the current request.
E.g. In the beginning, it’s 404. Then once something is found, it becomes 200. So technically, if in the controller the find is performed successfully, the ctx should also reflect this circumstance.
I agree with your but then my next question would be is chanching this behavoir a breaking change.
I’ll catch up on this during the office hours but if this is about Koa’s default 404, that’s not us it’s native koa
if you want a different status code/message besides 404 you need to return something
TLDR controlers don’t get a ctx update but middlewares do
because controllers don’t have “return chain”