Skip to content
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

Instructions on creating a middleware mention read but it probably should be find #2103

Closed
ri5h opened this issue May 5, 2024 · 1 comment
Assignees

Comments

@ri5h
Copy link

ri5h commented May 5, 2024

Link to the documentation page or resource

https://docs.strapi.io/dev-docs/backend-customization/middlewares#restricting-content-access-with-an-is-owner-policy

Describe the bug

In step 7 of documentation link above, under title: Restricting content access with an "is-owner policy", the steps to ensuring the methods to which middleware should apply is probably wrong.

After failing to see a log after adding a method read, I went to typescript types and tried find which worked.

I added some additional context and suggested fixes. let me know if you need further information.

ps.
I am probably using @strapi/strapi@4.12.4

Additional context

The route config I used to find this information was in node modules. I tried finding it in github but I don't think I can find a generated type in the monorepo, only relevant file was in a commit which may have been moved/renamed/etc.
https://github.com/strapi/strapi/blob/9c79921d22142a5de77ea26151550a14e4b12669/packages/core/types/src/types/core-api/router.ts#L29

Below is how it looks in my node modules.

export interface SingleTypeRouterConfig extends Generic {
  find?: HandlerConfig;
  update?: HandlerConfig;
  delete?: HandlerConfig;
}

export interface CollectionTypeRouterConfig extends Generic {
  find?: HandlerConfig;
  findOne?: HandlerConfig;
  create?: HandlerConfig;
  update?: HandlerConfig;
  delete?: HandlerConfig;
}

Suggested improvements or fixes

Either there was a change in another version which I am not using, maybe later versions use read instead of find, in which case, I am not sure how this could be solved, maybe a version switcher (example: https://laravel.com/docs/11.x/readme) at top is too big of a topic.

If not, just updating it should solve the issue I faced.

Related issue(s)/PR(s)

No response

@pwizla
Copy link
Collaborator

pwizla commented May 21, 2024

You're right, I've just fixed it. Thanks for reporting it!

@pwizla pwizla closed this as completed May 21, 2024
@pwizla pwizla self-assigned this May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants