Skip to content

luanlopez/application-hexagonal-arch-nestjs

Repository files navigation

Description

Application in NestJS, using a Hexagonal Architecture.

What is Hexagonal Architecture? / Port adapter

Hexagonal

Explanation and Example of Port-Adapter

Example

Ports

Inbound/Input/Driving Ports:

An input port (driving port) lets the application core to expose the functionality to the outside of the world.

Outbound/Output Ports / Driven Ports:

A type of interface that is used by the application core to reach things outside of itself

  • like getting some data from a database
  • consume api from other service

Adapters

Driving / Primary / Input Adapter

An adapter to use the implementation of the driving/input port. It could be a RESTful API controller, a MVC web controller, or a console app.

  • TicketController use TicketService from domain

Driven / Secondary / Output Adapter

An adapter to implement the driven/outbound port, It could be used to implement a database, a queue, a messaging system, etc.

  • TicketInMemory implement the outbound port It would be injected into the TicketService which is the implementation of the inbound port and the core business logic. The injection itself is handled by nestjs in ticket.module.ts

Installation

$ npm install

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

References

NestJS Clean Code Using Hexagonal Architecture

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published