Regaez/grav-plugin-api

refactor: should config support nested endpoints

Regaez opened this issue · 0 comments

The current config setup doesn't easily allow for configuring nested endpoints. For example, if we have POST /api/pages/searches, currently there are only config exposed for the methods for /api/pages. But we don't want to use the POST config, because that gives permissions to allow a user to create a new resource, when a search action is actually reading existing pages data, so it's actually more suitable to be a GET request.

Using a GET config in the code for a POST request is potentially confusing. Perhaps it would be better to rename the endpoint config to be use case (read/create/update/delete) rather than method (get/post/patch/delete).

Or perhaps the config should support nested endpoints within an endpoint config, e.g.

endpoints:
  /pages:
    get: 
      enabled: true
      auth: false
    endpoints:
      /searches:
        post:
          enabled: false 
          auth: false