Domain-Driven Design with loopback
extends base-domain
$ npm install base-domain-loopback
model definition is the same as base-domain
domain-dir/player.coffee
Domain = require('base-domain-loopback')
class Player extends Domain.Entity
@properties:
name: @TYPES.STRING
module.exports = Player
domain-dir/player-repository.coffee
Domain = require('base-domain-loopback')
class PlayerRepository extends Domain.LoopbackUserRepository
@aclType: 'owner' # access type. see README in loopback-with-admin
module.exports = PlayerRepository
main.coffee
domain = require('base-domain-loopback').createInstance
dirname: 'domain-dir'
baseURL: 'localhost:4157/api'
domain = require('base-domain-loopback').createInstance dirname: 'domain-dir'
modelDefinitions = domain.getModelDefinitions()
config =
server:
port: 4157
require('loopback-with-admin').run(modelDefinitions, config)