Code Monkey home page Code Monkey logo

express-ddd-api's Introduction

NodeJS - Express DDD API Template

ATENTION:

Delete git folder on root service after clone repository



To suggest or request adding changes, please clone the repository, create a new branch with your name/ISSUE and then request PR

NODE VERSION FOR DEVELOP AND PRODUCTION: 18.16.0

nvm install 18.16.0
nvm use 18.16.0

Linter

https://oxc-project.github.io/docs/guide/usage/linter-cli.html

Install dependencies

    npm install
    npm install @commitlint/cli @commitlint/config-conventional
    npm install husky --save-dev
    npx husky install

Creation process of commits and branches

The Husky Library has been implemented in the project to validate the process of creating commits and branches and thus follow a standard.

The commits must be created following a convention that is configurable in the file commitlint.config.js

Example of a correct commit

    git commit -m "feat(scope): info del commit"

Example of an incorrect commit

    git commit -m "feat(scope): Info del commit"

This would return an error similar to this:

⧗   input: feat(scope): Info del commit
✖   subject may not be empty [subject-empty]
✖   type may not be empty [type-empty]

✖   found 2 problems, 0 warnings
ⓘ   Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint

husky - commit-msg hook exited with code 1 (error)

The scope in optional, but it would be advisable to add it, since India where the changes sent in said Commit point.Example:

    git commit -m "feat(login): Added key recovery button"
    git commit -m "fix(register): resolved error by sending email to new users"

List of types of commits:

'build', 'chore', 'ci', 'docs', 'feat', 'fix', 'perf','refactor', 'revert', 'style', 'test'

They can review the convention for the commits in the following link: Convención

Branchs

The branch must also follow a convention and should start with any of the following prefixes: hotfix | bugfix | fix | feature

If you try to create an commitment in a branch that does not follow the standard, this will not allow the creation of the ADS and much less a push to that branch

To change the name of your current branch, use the following command

# git branch -m old-name new-name
# Example:
git branch -m mi-rama-actual feature/BUQ-123-info-de-rama

You can add the ticket number that way in the name of the branch so that it is associated with the ticket in jira

You can check the info a bit about the appointment of branches in the following link: Branch Flow

Postman

Postman collections are found in the root folder of the same name and are updated when changes arise in the endpoints if it is merited.

Update url for the specified domain for the tests in the postman environment attached to this repo

Modules and Use Case Creation

To create modules and use cases, there is a command that can be used in this way:

Module Creation

node command.js module -n module-name

all commands with npm

# Module with routes file, use case and controller
npm run command -- module -n moduleName

# Use Case
npm run command -- case -m moduleName -n useCaseName

# Mongo db Model
npm run command -- mdbmodel -n modelName

# Help
npm run command

This will create a module folder with its initial files in the folder [src/app]

/src
 |-/module-name
   |-/application
   | |-/use-case
   |   |- module-default.case.ts
   |   |- module-default.dto.ts
   |-/domain
     |-/ repositories
       |- iModuleName.repository.ts
   |-/insfrastructure
     |-/persistence
       |- moduleName.repository.ts
     |- module.controller.ts
   |-/routes
     |- module.routes.ts

Use Case Creation

node command.js -m module-name -n case-name

This will create a case of use within the indicated module [src/module-name/application/useCase-name], if the module does not exist the command omit the creation

/src
 |-/module-name
   |-/application
     |-/use-case
       |- module-default.case.ts
       |- module-default.dto.ts

You can see the help and commands available with the following command

node command.js -h

Docker

To load a sample with Docker at your premises, please follow these steps:

npm run build:local

or manual:

docker build -f script/Dockerfile -t apitest:local .

Then start the machine with the next configuration

docker run -d -p 3010:3001 --restart always --name api_base_testing --network pruebaslocal apitest:local

Note: Remember to disable the start of database in Server if you are not going to test with a database, otherwise, if database must be in the same network of the Docker instance of the API test

Note: Modify the environment variables in the Docker-test file before creating the local test image

express-ddd-api's People

Contributors

cquinterogoiar avatar xfxstudios 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.