Skip to main content

REPL - Herbs2REPL

Creates a REPL (Read Evaluate Print Loop) based on Herbs entities and usecases.

Herbs REPL

Installing

$ npm install herbs2repl

Using

srs/domain/usecases/_uclist.js:

module.exports = (injection) => {
return [
{ usecase: require('./createItem').createItem(injection), tags: { group: 'Items' } },
{ usecase: require('./updateItem').updateItem(injection), tags: { group: 'Items' } },
...
]
}

srs/infra/repl/index.js:

const usecases = require('../../domain/usecases/_uclist')
const repl = require('herbs2repl')

const main = async (injection) => {

// list of all use cases, initialized
const ucs = usecases(injection)

// your user for the REPL session
const user = {
canAddItem: true, canCreateList: true, canDeteleList: false,
canGetLists: true, canUpdateItem: true, canUpdateList: true
}

repl(ucs, user, {groupBy: "group"})
}

main().then()

Then run on your terminal:

$ node ./src/infra/repl