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.
https://github.com/DigiChanges/node-experience
NOTE: The v1 it's deprecated and don't have support in the future.
We can run the project directly with docker compose and then bash where the basic commands to feed the database are located.
- git clone https://github.com/DigiChanges/node-experience
- Create a folder on project root call it
dist
. - Install dependencies.
pnpm install
. - Copy
.env.dev
file to.env
. (.env.dev it's an environment example file) - Then execute
STAGE=dev docker-compose up --build
to up all containers.
docker-compose exec node bash dev.init.sh
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.
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
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.
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
pnpm test src/[Module]/Tests
Example Unique Test
pnpm test src/Item/Tests
NExp is MIT licensed.