Sample code for the Domain-driven design in JavaScript book. The code samples and additional resources are organized by chapter and example.
- Express App from chapter 1.
No sample code in this chapter.
- Underscore Source code is available on Github.
- Prisoner Transfer prisoner transfer module, including the basic layout for the tests, and features runnable.
- Weapons: Example how aggregation of weapons could work, calling deep inside
objects, which is most likely a bad idea.
node weapons/weapons.js - Composition and Inheritance: See the appropriate subfolder.
- Domain Objects: See chapter 3 prisoner transfer.
- My Mock: Example mock, built using a simple object, run via
node my_mock/my_mock.js - Simple Object: Battle Orc
node simple_objects/battle_orc.jsOrcnode simple_objects/orc.js - Sinon Example: Example usage
sinonfor mocking, run vianpm installto install dependencies, andnpm test.
- ExaggeratingOrc
exaggerating_orc.js, shows working with private and public methods - not a value object
not_value_objects.js, show how objects can be modified - Value object example based on coins,
coin.js - Using value objects in wallet
wallet.js - Events
event.js - Orcs repository
orcs.js - Alternative active record style getting orcs
orcs_ar.js - Sending letter via a postman
postman.js
- sample notifier
npm installto load the dependencies andnpm run notifierto run the code is innotifier.js
- sample math
node math.js - using array functions to process
node transport_time.js - loggable example
node oo_orc.js - state in basic objects example
node thing.js - events
node events.js - jumping counter managing state
node counter.js
- pjax-example: run
npm installin thechapter_8/pjax-examplefolder and runnpm startto try it out. - ember-example: run
npm installin thechapter_8/ember-examplefolder and runnpm startto try it out. deactivate_button.htmljquery example deativating a button inline, to try it simply open in a browser.- car configuration example to work with constraints and logic
node car_configurator.js