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

Herbarium - Generate files with Herbarium #85

Closed
dalssoft opened this issue Dec 19, 2021 · 0 comments
Closed

Herbarium - Generate files with Herbarium #85

dalssoft opened this issue Dec 19, 2021 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed severity-minor Item is not urgent wip work in progress

Comments

@dalssoft
Copy link
Member

With the new release of Herbarium, CLI can generate files using it.

The best implementation reference is To Do List.

All entities, use cases and repositories should be added to Herbarium repo:

entity

...
const { herbarium } = require('@herbsjs/herbarium')

const Item =
  entity('Item', {
  ...
  })

module.exports =
  herbarium.entities
    .add(Item, 'Item')
    .entity

use case

...
const { herbarium } = require('@herbsjs/herbarium')
const { Item } = require('../entities/item')

const createItem = (injection) =>
  usecase('Create Item', {
    ...
  })

module.exports =
  herbarium.usecases
    .add(createItem, 'CreateItem')
    .metadata({ group: 'Items', operation: herbarium.crud.create, entity: Item })
    .usecase

repository

const { herbarium } = require('@herbsjs/herbarium')
const { Item } = require('../../../domain/entities/item')

class ItemRepository extends Repository {
...
}

module.exports =
    herbarium.repositories
        .add(ItemRepository, 'ItemRepository')
        .metadata({ entity: Item })
        .repository

And all glues like rest, gql and knex can use it:

Ex: gql mutation

const { herbarium } = require('@herbsjs/herbarium')

const usecases = herbarium.usecases
    .findBy({ operation: [herbarium.crud.create, herbarium.crud.update, herbarium.crud.delete] })
    .map(e => e.usecase)

const mutations = usecases.map(usecase => usecase2mutation(usecase(), defaultResolver(usecase)))

Rest, GQL, Herbs Shelf and REPL using Herbarium can be found on To Do List.

@dalssoft dalssoft added the enhancement New feature or request label Dec 19, 2021
@jhomarolo jhomarolo added help wanted Extra attention is needed severity-minor Item is not urgent labels Dec 24, 2021
@dalssoft dalssoft added the wip work in progress label Feb 7, 2022
dalssoft added a commit that referenced this issue Feb 7, 2022
BREAKING CHANGE: Since there is no more 'index.js' as lists for uc and entities, it will no longer
work with old projects.

#85
github-actions bot pushed a commit that referenced this issue Feb 20, 2022
# [2.0.0](v1.10.4...v2.0.0) (2022-02-20)

### Bug Fixes

* **graphql:** fix graphql gql generation ([ca4a3f7](ca4a3f7))
* **herbsshelf:** fix herbarium link with herbsshelf ([757c131](757c131))

### Features

* **herbarium:** improve node_module dependencies ([ede6c64](ede6c64))
* **herbarium:** use Herbarium for use cases, entities and repos ([ca545b6](ca545b6)), closes [#85](#85)
* **migration:** create new migrations for entity on `herbs update` ([ec3c907](ec3c907))
* **start info:** improved start info with herbsshelf endpoint ([939cc21](939cc21))

### BREAKING CHANGES

* **herbarium:** Since there is no more 'index.js' as lists for uc and entities, it will no longer
work with old projects.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed severity-minor Item is not urgent wip work in progress
Projects
None yet
Development

No branches or pull requests

2 participants