This is another Express + TypeScript + DDD (Domain Driven Design patterns) + IoC/DI (Inversion of control and Dependency injection) + Primsa ORM + API REST boilerplate.
yarn install
yarn prisma generatecp .env.dist .envYou 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"
yarn devyarn test
yarn coverageyarn buildWe 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 studioAWS 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/
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 upcurl http://localhost:8080
curl http://localhost:8080/health_checkExample JSON response (/health_check):
{
"id": "cd6f2876-5de5-4433-b0b9-fb7a8d47abbb",
"success": true,
"date": "2021-02-07T20:13:21.720Z"
}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- 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, SonarCloud Scan integration