Code Monkey home page Code Monkey logo

digichanges / node-experience Goto Github PK

View Code? Open in Web Editor NEW
53.0 7.0 37.0 74.56 MB

Hello! NExp (Node Experience) is a boilerplate for Node, which makes use of a Hexagonal architecture, in addition to all the power of TypeScript that combined allow a perfect cohesion thus achieving a clean and at the same time very powerful implementation.

Home Page: https://nexp.docs.digichanges.com

License: MIT License

TypeScript 89.79% Dockerfile 0.35% JavaScript 7.51% Shell 0.49% Makefile 1.04% Handlebars 0.44% PLpgSQL 0.38%
typescript mongodb docker nodejs boilerplate-application innovation-labx

node-experience's Introduction

Welcome to Node Experience!

Sonarcloud Status License: MIT

logo NExp

Basic Description

Hello! NExp (Node Experience) is a boilerplate for Node, which makes use of a Clean Architecture + DDD, with TypeScript that combined allow a perfect cohesion thus achieving a clean and at the same time very powerful implementation.

Base project

https://github.com/DigiChanges/node-experience

Docs

Boilerplate Documentation

Boilerplate Documentation

NOTE: The v1 it's deprecated and don't have support in the future.

Quick Start

We can run the project directly with docker compose and then bash where the basic commands to feed the database are located.

  1. git clone https://github.com/DigiChanges/node-experience
  2. Create a folder on project root call it dist.
  3. Install dependencies. pnpm install.
  4. Copy .env.dev file to .env. (.env.dev it's an environment example file)
  5. Then execute STAGE=dev docker-compose up --build to up all containers.

docker-compose exec node bash dev.init.sh

Installation

First, install nexp-cli using npm (we assume you have pre-installed node.js).

npm install -g nexp-cli

Then generate your new project:

nexp-cli create

Each module is divided by business domain:

  • Item
  • Notification

There are also two particular cases:

  • Config
  • Shared

The directory structures for business domains are as follows:

Folder structure of a domain (business logic)

├── Domain
│   ├── Entities
│   ├── Exceptions
│   └── Services
│   └── UseCases
├── Infrastructure
│   ├── Repositories
│   ├── Schema
│   └── Seeds
├── Presentation
│   ├── Commands
│   ├── Controllers
│   ├── Criterias
│   ├── Exceptions
│   ├── Handlers
│   ├── Middlewares
│   ├── Requests
│   └── Transformers
├── Tests
│   ├── Fixtures

Tip I know it may sound repetitive, but it is not a framework. NExp is a set of tools or libraries working together through a common structure. All structural code within this project is not fixed and can be changed freely.

Supabase integration

In the infrastructure folder there is a file called supabase_permissions.sql this file is used to manage permissions with these tables.

  • roles
  • permissions
  • users_has_roles
  • roles_has_permissions

And a function call get_authorization

Advantages

The advantages of using this boilerplate are to save time thinking about certain basic structures common to any project to make an API without having to get everything from scratch.

As it is only a boilerplate, you have the freedom to structure the code whatever you want.

Common structures found within this project are:

  • Fastify's integration.
  • MikroORM and Mongoose Integration.
  • Basic push Notification and Email with nodemailer.
  • Business logic independent of the HTTP and persistence libraries.
  • Supabase integration middleware.

Quick Test

Execute TEST Environment

To run the tests, we need to install the packages and transpile the code, we also need the .env environment variable to exist.

pnpm test

Test different folder

pnpm test src/[Module]/Tests

Example Unique Test

pnpm test src/Item/Tests

Docs

POSTMAN Documentation

License

NExp is MIT licensed.

node-experience's People

Contributors

anne-tf avatar dependabot[bot] avatar figaarillo avatar gaston3408 avatar gavogar avatar kmery avatar lucho10mdq avatar murzbul avatar ngrosso avatar roxnnyabarriosc avatar roxnnyabarrioscwingsoft avatar rutito2010 avatar segoviadanielm avatar semantic-release-bot avatar smartnetar avatar snyk-bot avatar valeriabassi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-experience's Issues

Refactor: auth management NEXP to make it compatible with keycloak

Se debe re hacer la parte de authorization management en NExp. Se tiene que integrar la logica de los scopes, permisos, resources y politicas para que sea compatible con keycloak. Esto quedaria para la siguiente version. Solo se podria asignar roles a los users.

Add mikroORM migration.

Primero probar que la instalacion sea correcta y luego documentar en el readme el paso para generar la migracion.

test.build.sh File

node-experience/test.build.sh
este archivo ya no se usa o quedó con las antiguas rutas y con un script antiguo

  • "dist/src/command.js"
  • yarn start:test

Crear la configuracion unica mediante un archivo

export function config2 =
{
APP: {
DEFAULT: {
type: 'string',
default: 'FastifyBootstrapping'
env: false
},
PATH: {
type: 'string',
env: true,
var: 'APP_PATH'
},
PORT: { // Por defecto se entiende que es APP_PORT ya que no existe el campo var
type: 'port',
default: 8090
}
},
MESSAGE_BROKER_URI: {
type: 'uri',
default: 8090
}
}
Modo de uso

MainConfig.getValues().app.default === APP_DEFAULT

MainConfig.getValues().messageBrokerUri === MESSAGE_BROKER_URI

Caracteristicas

type: Los tipos posibles. Por ahora podrian ser todos los que vienen de envalid.

string
boolean
uri
email
port
number

default: Valor por defecto. Que sucede si no tenemos valor por defecto? Es valido solo en casos en donde no sean variables de entorno.
env: true o false, si viene de una variable de entorno. Si no existe la key se toma como false.

Filter and Sort without config

It is necessary to modify the way in which filters and sorts that do not exist in a request are handled so that it throws an error if that configuration does not exist to maintain coherence between requests with functional filters or not.

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.