How to Get Started With a Clean Architecture Template for NodeJS, Ts.ED and TypeScript

One of the most time-consuming tasks when starting a project from scratch is the creation of the initial scaffolding, the folder structure, the configuration of linters and formatters, the configuration of tests, etc. They are almost always the same tasks, changing certain details to adapt them to the team’s development conventions. On the other hand, there are also common tasks in most projects, such as for example, authentication and/or authorization and user management, the definition of the OpenAPI specification, creation of a common logger, etc.

Because of this, I decided to create a base template of a REST API created with NodeJS, using Ts.ED as the base framework and TypeScript as the programming language. This template tries to follow the principles of Domain Driven Design and implements a Clean Architecture/Hexagonal Architecture to try to rely as little as possible on the infrastructure and the framework while keeping in mind at all times the language and the needs of the business logic.

📣 This is an opinionated template. The architecture of the code base and the configuration of the different tools used has been based on best practices and personal preferences.

🧰 Technologies and tools used

  • Built using Typescript
  • Built using Express Framework: Fast, unopinionated, minimalist web framework for node.
  • Built using Prisma: Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite & MongoDB
  • Built using Ts.ED: Ts.ED is a Node.js Framework on top of Express/Koa.js. Written in Typescript, it helps you build your server-side application easily and quickly. If you want to start a complete out-of-the-box project or fully customize it yourself, Ts.ED will guide you there! This framework is extremely powerful and easy to use. It is really worth it.
  • JWT authentication and role-based authorization using custom middleware
  • OpenAPI definition
  • Fully configured logger with Winston and Morgan
  • Unit, Integration, and E2E tests using Jest and Supertest
  • Linting with ESLint
  • Formatting with Prettier
  • Spell check
  • Git hooks with Husky and lint-staged
  • Containerized using Docker and Docker Compose
  • Path aliases support
  • Commit messages must meet the format of the conventional commit
  • GitHub Actions
  • Makefile as the project entry point
  • A lot of emojis 🛸

🚀 Quick start

git clone
npm install
make start/db # This step will create a Docker container with the database (MariaDB). It may take some time, so be patient before running the next command.
npm run prisma:generate
npm run prisma:migrate
npm run prisma:seed
npm run dev
http://localhost:5000/api/docs # Sample username and password: janedoe / 123456
# Sample username and password: janedoe / 123456

🤝 Contributing

Just fork and open a pull request. All contributions are welcome 🤗

GitHub repository:

Thank you for taking the time to read this post. You rock! 🤘

. . . comments & more!

Source link



  • io game

    December 22, 2022 at 7:55 pm

    Somebody necessarily assist to make critically articles I
    might state. That is the very first time I frequented your website page and so far?
    I surprised with the analysis you made to create this actual put up extraordinary.
    Fantastic task!


    • admin

      December 23, 2022 at 7:36 am

      Thank you. We will keep posting more such articles.


  • sevgiliye kitap

    January 6, 2023 at 12:09 pm

    Have you ever considered creating an e-book or guest
    authoring on other blogs? I have a blog based upon on the same subjects you discuss and would really like to have you share
    some stories/information. I know my readers would enjoy your work.
    If you are even remotely interested, feel free to shoot me an e-mail.


  • agario

    February 2, 2023 at 9:45 pm

    Today, I went to the beachfront with my kids. I found a sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She put
    the shell to her ear and screamed. There was a
    hermit crab inside and it pinched her ear. She never wants to go back!

    LoL I know this is totally off topic but I had to tell someone!



    February 4, 2023 at 12:25 am

    Hmm it looks like your blog ate my first comment (it was super long) so I guess I’ll just sum it up what
    I wrote and say, I’m thoroughly enjoying your blog.
    I too am an aspiring blog writer but I’m still new to the whole thing.
    Do you have any suggestions for beginner blog writers?
    I’d certainly appreciate it.


Leave a Reply

Your email address will not be published. Required fields are marked *