Skip to content

Abdulmoiz-Ahmer/todo-api

Repository files navigation


TODO-API

A todo application build with nodejs, expressJs, MongoDb, clean code architecture and tdd

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Testing
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

About The Project

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 (todo). 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
  • CircleCI pipeline to trigger deployment on push
  • Digital Ocean Droplet

(back to top)

Built With

(back to top)

Getting Started

Prerequisites

  • Nodejs

  • yarn

    npm install -g yarn

Installation

  1. Clone the repo

    git clone https://github.com/Abdulmoiz-Ahmer/todo-api.git
  2. Install NPM packages

    yarn install
  3. Enter your Port, mongo user and password in .env

    PORT=4000
    MONGO_USER=
    MONGO_PW=
  4. To seed database run

    yarn seed
  5. To run

    yarn start
      or
    docker build . -t todo-api;
    docker run -p 4000:4000 todo-api;

(back to top)

Usage

This repository has been used with a todo app and it's repository.

(back to top)

Testing

  • Acceptance testing: Acceptance tests are in the tests/acceptance directory. Can be invoked with:

    yarn test:acceptance
  • Contracts(postman collection): Contract tests are exported from postman application are in the directory tests/contracts. Can be invoked with:

      yarn test:contracts
  • Contracts(pact): Contract tests are exported from postman application are in the directory tests/cdc. Can be invoked with:

      yarn test:verify-contracts
  • Unit testing Unit Tests tests are exported from postman application are in the directory tests/unit. Can be invoked with:

      yarn test:unit

Sample test run report of circleci pipeline

Libraries used for testing:

Note: To invoke all kind of tests use:

 yarn test

(back to top)

Contributing

Contributions of any kind are
greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License.

(back to top)

Contact

Your Name - Abdulmoiz Ahmer - abdulmoiz1996@gmail.com

Project Link: https://github.com/Abdulmoiz-Ahmer/todo-api

(back to top)

Acknowledgments

(back to top)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages