The guide to understand Hexagonal Architecture (a.k.a Ports and Adapters) in JavaScript.
Click here to see my publication on my blog →
ℹ️ This publication is being maintained right now. This means that some topics may be out of date.
This is a sample repository for my "Hexagonal Architecture Distilled in JavaScript" publication.
The code writing style was motivated by the familiarity of JavaScript programmers.
The design was as simple as possible in order not to obscure the practical examples of Hexagonal Architecture concepts.
I suggest that the consumer of this content does not get attached to peripheral concepts (Decorator design pattern, etc). Focus on Ports and Adapters!
- Ports - @/hexagon/ports/readme.md
- Adapters - @/adapters/readme.md
- Use Cases - @/hexagon/usecases/readme.md
The diagram below is designed to be familiar with the C4 pattern component diagram.
- Install Node.js >= 14
- Open this repo and install dependencies
- Run:
npm run start
- Having the node installed, open this repo and run:
npm run docker:up
- If you want to disassemble the composition, run:
npm run docker:down
- Unitary tests, run:
npm run test:unit
- Integration tests, run:
npm run test:integration
- Both tests, run:
npm run test
- Having the environment mounted (both local or docker), run:
npm run test:create-a-post
and copy the "_id" returned property - Input above returned property in TESTABLE_POST_ID variable on e2e/docker/get-a-specific-post.test.js and run:
npm run test:get-a-specific-post
- Input above returned property in TESTABLE_POST_ID variable on e2e/docker/edit-a-specific-post.test.js and run:
npm run test:edit-a-specific-post
- Run:
npm run test:list-all-posts