herbsjs / herbs2rest

Create a REST API based on HerbsJS
MIT License
2 stars 13 forks source link

ID field: use ID metadata from entity #21

Closed dalssoft closed 2 years ago

dalssoft commented 2 years ago

With the upcoming release of the "ID field" feature (https://github.com/herbsjs/gotu/issues/46), it would be possible to read the entity's metadata and, as a convention, use those IDs that today need to be explicitly defined.

const controllerList = [
  {
    name: 'lists',
    getAll: { usecase: require('../usecases/getLists'), controller: require('../controller') },
    getById: { usecase: require('../usecases/getLists'), id: 'listId' },       // <---- `id` would not be necessary
    post: { usecase: require('../usecases/createList') },
    put: { usecase: require('../usecases/updateList') },
    delete: { usecase: require('../usecases/deleteList') }
  }
]

Explicitly defining IDs would still be possible, but not mandatory for entities with IDs.

mtperesvx commented 2 years ago

I can work on this issue.

dalssoft commented 2 years ago

@mtperesvx did you send a PR?

mtperesvx commented 2 years ago

@dalssoft hi. https://github.com/herbsjs/herbs2rest/pull/33#event-6888720180