Giter VIP home page Giter VIP logo

nestjs-hexagonal-architecture-example's Introduction

Nest Logo

NestJS Hexagonal Architecture Example

Example of how to create a NestJS service using hexagonal architecture.

nodejs node typescript npm fastify swc swc docker

👀 Motivation

The main idea of this project is to show how we can create a NestJS service using the hexagonal architecture. Note that this repository is not a template for starting new projects so we will not keep it up to date in terms of dependencies, vulnerabilities or new practices, if you are looking for a new template we recommend you to check the project templates section.

🤩 Project templates

Are you thinking in start new projects in nestjs, other frameworks or create a super fancy library? I recommend you to check the following templates I have been working on:

🧑‍💻 Developing

First, we will need to create our .env file, we can create a copy from the example one:

cp .env.example .env

The project is fully dockerized 🐳, if we want to start the app in development mode, we just need to run:

docker-compose up -d my-service-dev

This development mode with work with hot-reload and exposing a debug port, the 9229, so later we can connect from our editor to it.

Now, you should be able to start debugging configuring using your IDE. For example, if you are using vscode, you can create a .vscode/launch.json file with the following configuration:

{
  "version": "0.1.0",
  "configurations": [
    {
      "type": "node",
      "request": "attach",
      "name": "Attach to docker",
      "restart": true,
      "port": 9229,
      "remoteRoot": "/app"
    }
  ]
}

Also, if you want to run the production mode, you can run:

docker-compose up -d my-service-production

This service is providing just a health endpoint which you can call to verify the service is working as expected:

curl --request GET \
  --url http://localhost:3000/health

If you want to stop developing, you can stop the service running:

docker-compose down

⚙️ Building

npm run build

✅ Testing

The service provide different scripts for running the tests, to run all of them you can run:

npm run test

If you are interested just in the unit tests, you can run:

npm run test:unit

Or if you want e2e tests, you can execute:

npm run test:e2e

💅 Linting

To run the linter you can execute:

npm run lint

And for trying to fix lint issues automatically, you can run:

npm run lint:fix

nestjs-hexagonal-architecture-example's People

Contributors

alberthernandez avatar

Stargazers

João Vitor avatar HaiDoan avatar paikwiki avatar JesúsB avatar  avatar Eva avatar Diego Gomez avatar Sebastian Perez avatar Rubén avatar Jiho Lee avatar 우태현 禹泰賢 avatar Mikael Hadler avatar Dan Colmenares avatar yahia avatar Oscar Vargas avatar Pedro Toribio avatar Manuel Garcia avatar Josep Servat avatar Mahabub avatar Marcelo Dias avatar Luis M Torres avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.