This is another Express + TypeScript + DDD (Domain Driven Design patterns) + IoC/DI (Inversion of control and Dependency injection) + Primsa ORM + API REST boilerplate.

Overview

Express-TS-DDD REST API

TypeScript GitHub Repo Size Github CI codecov License MIT

This is another Express + TypeScript + DDD (Domain Driven Design patterns) + IoC/DI (Inversion of control and Dependency injection) + Primsa ORM + API REST boilerplate.

Installation and Configuration

yarn install
yarn prisma generate

Generate .env file

cp .env.dist .env

You have to configure local environment variables such as PostgreSQL connection string with your own parameters inside .env file. These are the default values:

PORT=3000
APP_NAME="express-ts-ddd"

# Prisma supports the native connection string format for PostgreSQL, MySQL and SQLite.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings

APP_DATABASE_URL="postgresql://user:password@localhost:5432/dbname?schema=public"
APP_LOG_LEVEL="debug"

COGNITO_USER_POOL="your_cognito_user_pool"
COGNITO_CLIENT_ID="your_cognito_client_id"
COGNITO_REGION="your-aws-region-x"

Development with nodemon (Runs on 3000 port)

yarn dev

Run tests and generate coverage report

yarn test
yarn coverage

Build/Compile JS (to /dist folder)

yarn build

Access Prisma Studio (Database preview for dev)

We are using Prisma ORM to handle database connections, migrations, code schema management and also its studio web UI to preview database content in development environment. Please check Prisma documentation for more detailed information.

yarn prisma studio

Authentication with AWS Cognito

AWS Cognito is implemented as default authentication service. Please, check documentation on how to configure it for more details: https://aws.amazon.com/cognito/getting-started/


Docker Compose

This project is ready to work with docker-compose 3.8 to initalize the needed stack during development process. To start working run the following commands:

docker-compose build
docker-compose up

Working docker compose environment (Port 8080)

curl http://localhost:8080
curl http://localhost:8080/health_check

Example JSON response (/health_check):

{
  "id": "cd6f2876-5de5-4433-b0b9-fb7a8d47abbb",
  "success": true,
  "date": "2021-02-07T20:13:21.720Z"
}

Build Docker image for production

You can build an optimized Docker production-ready image with the standard command:

docker build -t express-ts-ddd .

And then run the container passing environment variables within the initialization:

docker run --rm -it -p 3000:3000 \
  -e NODE_ENV=production \
  -e APP_DATABASE_URL="postgresql://user:password@host:5432/dbname?schema=public" \
  -e COGNITO_USER_POOL="your_cognito_user_pool" \
  -e COGNITO_CLIENT_ID="your_cognito_client_id" \
  -e COGNITO_REGION="your-aws-region-x" \
  --name express-ts-ddd express-ts-ddd

Next steps

  • Adds Prisma ORM with PostgreSQL implementation
  • Adds Github CI + CI testings
  • Adds better documentation
  • Kubernetes support (Local environment microk8s, minikube...)
  • Docker for development (docker-compose) and production environments
  • Global logger service (Morgan + Winston)
  • Integration basic testing (supertest)
  • Authentication service with Cognito
  • Adds test coverage report, codecov integration
You might also like...

TypeScript Transformer for injection-js

TypeScript Transformer for injection-js TypeScript Transformer for injection-js, inspired by angular-cli. Why need this No more emitDecoratorMetadata

Dec 4, 2022

This is a vanilla Node.js rest API created to show that it is possible to create a rest API using only vanilla Node.js

This is a vanilla Node.js rest API created to show that it is possible to create a rest API using only vanilla Node.js. But in most cases, I would recommend you to use something like Express in a production project for productivity purposes.

Jul 19, 2022

Blog application api in Node.js express.js sequelize ORM and MYSQL Database

Node Express Mysql Sequelise Blog System Api Node api with express mysql sequelise Usage To get started with this api follow the steps below $ git clo

Nov 9, 2022

Set up and build a Node.js REST API using Typescript, Express, Mongoose with a maintainable and scalable structure.

Introduction Create a maintainable and scalable Node.js REST API with TypeScript, Express and Mongoose. The project structure is based on MVC and foll

Nov 18, 2022

Simple REST API using Express with TypeScript, PostgreSQL, and MySQL to practice the Clean Architecture by Uncle Bob.

Clean-Architecture Simple REST API using Express with TypeScript, PostgreSQL, and MySQL to practice the Clean Architecture by Uncle Bob. About This RE

Oct 16, 2022

A Node.js REST API example built with Express and Typescript that can be used as template for creation of new servers.

api-example-firebase-nodejs A Node.js REST API example built with Express and Typescript that can be used as template for creation of new servers. The

Nov 25, 2022

A free book that talks about design patterns/techniques used while developing with React.

React in patterns 📚 A free book that talks about design patterns/techniques used while developing with React. Book GitBook Web PDF Mobi ePub Translat

Dec 30, 2022

Open Source projects are a project to improve your JavaScript knowledge with JavaScript documentation, design patterns, books, playlists.

Open Source projects are a project to improve your JavaScript knowledge with JavaScript documentation, design patterns, books, playlists.

It is a project I am trying to list the repos that have received thousands of stars on Github and deemed useful by the JavaScript community. It's a gi

Aug 14, 2022

Open source privacy notice design patterns.

Open source privacy notice design patterns.

Design-first privacy notice template The Juro Privacy Notice is an open source project by https://juro.com and https://stefaniapassera.com/. A couple

Nov 10, 2022
Owner
J.D.
*** *** ** I - Love - Programing ** *** *** ===React, Next.js And Unity Engine===
J.D.
Get-A-Room example application using Domain Driven Design and Clean Architecture. Written in TypeScript and deployed to AWS with a serverless stack.

Domain Driven Microservices on AWS in Practice This project provides a Domain Driven Design & Clean Architecture-informed, multi-service event-driven

Mikael Vesavuori 5 Dec 31, 2022
This package support to build a complex application with domain driven design.

The library implement Domain Driven Design for Nodejs base on Typescript. Description This package support to build a complex application with th doma

null 11 Nov 7, 2022
A functional, immutable, type safe and simple dependency injection library inspired by angular.

func-di English | 简体中文 A functional, immutable, type safe and simple dependency injection library inspired by Angular. Why func-di Installation Usage

null 24 Dec 11, 2022
A simpliest DI(Dependency Injection) example

di-example A simpliest DI(Dependency Injection) example showing how dependency injection actually works. How to Run Install dependency with your favor

Kelly 4 Dec 6, 2022
Moject is a IoC container and an app factory built around the modules idea of Angular and NestJs.

Moject Moject is an IoC container and an app factory package built around the modules idea of Angular and NestJs. Usage npm install moject Use @Mo

Alexander 4 Dec 4, 2022
A complete guide for learning Object Oriented Programming Pillars, SOLID Principles and Design Patterns with TypeScript!

Object Oriented Programming Expert With TypeScript This repository is a complete guide and tutorial for the principles and techniques of object-orient

Ahmad Jafari 44 Dec 29, 2022
Learn design patterns through games with TypeScript and Phaser 🕹️

Welcome to Design patterns gamified! I created this repo to teach design patterns through games. Each folder contains a tiny game that demonstrates ho

Paula Santamaría 41 Nov 10, 2022
Playground for studying design patterns, solid principles, GoF, testing and more with TypeScript

TypeScript design patterns study Playground for studying design patterns, solid principles, GoF, testing and more with TypeScript Index TypeScript des

Lucas Souza 9 Dec 9, 2022
The most often-used OOP design patterns in TypeScript

The most often-used OOP design patterns Generating patterns Factory method Abstract factory Builder Prototype Singleton Structural patterns Adapter Br

Rodion 4 Mar 11, 2022
A testing focused Remix Stack, that integrates E2E & Unit testing with Playwright, Vitest, MSW and Testing Library. Driven by Prisma ORM. Deploys to Fly.io

Live Demo · Twitter A testing focused Remix Stack, that integrates E2E & Unit testing with Playwright, Vitest, MSW and Testing Library. Driven by Pris

Remix Stacks 18 Oct 31, 2022