A project build with nodejs, expressJs, MongoDb and clean code architecture.
·
Report Bug
·
Request Feature
Table of Contents
These are the services based on the clean code architecture. The reason i prefer to use this architecture is because it makes change easier and in world of software only change is constant.
Few words about the above architecture:
-
Inner Layer Models. Handles the creation, validation and reading of our entities (account). Note that this should be custom logic and not include the DB implementation of models (e.g. in Mongoose DB ORM, their models should be encapsulated in the DB layer below). Our model schemas live here. DB. Our choice of DB (in memory, MongoDB, SQL), this is independent of the model. Note that in Clean Architecture this is considered an outer layer framework, but for practical applications I find it easier to place it inner and have the data-access layer depend on it rather than injecting it in.
-
Middle Layer Data-Access. Handles transfer between the DB (like an ORM). Depends on the model to validate and create the entity in DB. The key is to have a consistent & custom API that all outer layers communicate with. Testing here will ensure that replacing or using multiple DBs doesn't break anything further upstream.
-
Outer Layer Drivers. Represents the UI or interface (Web or CLI). It communicates only with the data-access layer.
For Deployment
- Husky pre-push to trigger tests
-
yarn
npm install -g yarn
-
Clone the repo
git clone https://github.com/kaleemullahdev/cross-functional-test-api.git
-
Install NPM packages
yarn install
-
Enter your Port, mongo user and password in
.env
PORT=4000 DATABASE_SERVICE= DATABASE_USER= DATABASE_PASSWORD= DATABASE_PORT= CRYPTO_SECRET=
-
To seed database run
yarn seed
-
To run
docker-compose -f server.yaml up
This repository has been used with a test app and it's repository.
-
Unit testing Unit Tests tests are exported from postman application are in the directory tests/unit. Can be invoked with:
yarn test:unit
Libraries used for testing:
Note: To invoke all kind of tests use:
yarn test
Contributions of any kind are
greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License.
Your Name - Kaleem Ullah - [email protected]
Project Link: https://github.com/kaleemullahdev/cross-functional-test-api.git