概要
Clean Architecture implementation written in NodeJS
Web・アプリ開発計測したスター増加
- 24時間
- 0
- 7日間
- 0
- 15日間
- 0
- 1か月
- 履歴を収集中
期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。
README.md
オリジナルNode Clean Architecture

Table of Contents
This backend implements a RESTful CRUD interface for users and complies with Eric Evan's DDD and Uncle Bob's Clean Architecture which is briefly explained here in the document.
It also exposes a /docs/ endpoint for further reference and /coverage/ for test coverage.
Libs
- Restify
- Mongoose
- Lodash FP Functional Programming version
- Awilix as Dependency Injection container
- dotenv
Installation
docker-compose up -d
cp .env.example .env
npm start
You should get
restify listening at http://[::]:8080
connected to MongoDB database!
Access http://localhost:8080/docs/ and http://localhost:8080/coverage/
Testing
npm test
It uses an in-memory DB to run tests so you don't need to have mongodb up and running
Clean Architecture

Folder structure
└ application → Application services layer
└ use_cases → Application business rules
└ domain → Enterprise core business layer such as domain model objects (Aggregates, Entities, Value Objects) and repository interfaces
└ infrastructure → Frameworks, drivers and tools such as Database, the Web Framework, mailing/logging/glue code etc.
└ config → Application configuration files, modules and services
└ container.js → Module that manage service implementations by environment
└ database → Database ORMs middleware
└ schemas → Mongoose schemas
└ repositories → Implementation of domain repository interfaces
└ webserver → Restify Web server configuration (server, routes, plugins, etc.)
└ server.js → Restify server definition
└ ports/http → Adapters and formatters for use cases and entities to external agency such as Database or the Web
└ UserController.js → Restify route handlers
└ routes.js → Restify route definitions
└ errors.js → Standard errors for the whole application
└ index.js → Main application entry point
The Dependency Rule
The overriding rule that makes this architecture work is The Dependency Rule. This rule says that source code dependencies can only point inwards. Nothing in an inner circle can know anything at all about something in an outer circle. In particular, the name of something declared in an outer circle must not be mentioned by the code in the an inner circle. That includes, functions, classes. variables, or any other named software entity.
Extracted from https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html#the-dependency-rule
Typical Request

Troubleshooting
Log connected to MongoDB database! doesn't appear
The backend uses its own database (users) to run its business logic, so you need to ensure this database is created with proper user credentials. The script mongo-init.js is run when docker-compose up runs for the first time.
Check in docker-compose logs mongo to see if something unusual is happening
I'm getting EADDRINUSE upon application start
You need port 8080 to be free in order to boot up the application. Check if it's already in use and shut the application down before you npm start again
Stack Report
rasouza/node-clean-architecture
| 28 Tools used |
3 Contributors |
10/11/23 Report generated |
06/06/22 Last commit date |
|---|
Languages (2)
|
JavaScript |
CSS 3 |
Frameworks (1)
|
Fastify v3.9.2 |
Data (1)
|
Mongoose v5.10.3 |
DevOps (7)
|
Dotenv |
ESLint |
Git |
Jest v28.1.0 |
Yarn |
nodemon v2.0.4 |
npm |
Other (2)
|
Shell |
semantic-release |
Open source packages (15)
npm (15)
| NAME | VERSION | SOURCE FILE |
|---|---|---|
| @semantic-release/git | v10.0.1 | yarn.lock |
| @types/jest | v28.1.1 | yarn.lock |
| cross-env | v7.0.3 | yarn.lock |
| dotenv | v8.2.0 | yarn.lock |
| eslint-config-standard | v16.0.2 | yarn.lock |
| eslint-plugin-import | v2.22.1 | yarn.lock |
| eslint-plugin-jest | v26.5.3 | yarn.lock |
| eslint-plugin-node | v11.1.0 | yarn.lock |
| eslint-plugin-promise | v4.2.1 | yarn.lock |
| eslint-plugin-standard | v5.0.0 | yarn.lock |
| mongoose | v5.10.3 | yarn.lock |
| nyc | v15.1.0 | yarn.lock |
| pino | v6.9.0 | yarn.lock |
| pino-pretty | v4.3.0 | yarn.lock |
| semantic-release | v19.0.2 | yarn.lock |
Generated via Stack Reports
関連プロジェクトを探す
読み込み中…