- TypeScript
- node - runtime
- express - Framework
- prisma - ORM
- postgres - DB
- Pulumi - The infra framework
- RDS (Postgres) - DB
- ECR - To store your docker images
- ECS Task - To run your Rest API container
- Load Balancer - To expose your Rest API to the world
In order to run the server, you must create a .env file It is not in the repo.
echo "NODE_ENV=development
IS_CLOUD=false
PORT=3001
JWT_PRIVATE_KEY=<RSA PRIVATE KEY>
JWT_PUBLIC_KEY=<RSA PUBLIC KEY>
JWT_TOKEN_EXPIRY=1h
JWT_REFRESH_TOKEN_EXPIRY=7d
DATABASE_URL=postgresql://template_db_user:Aa123456@localhost:5432/template_db?schema=public" > .env
$ openssl genrsa -out private.pem 2048
$ openssl rsa -in private.pem -pubout -out public.pem
LINUX:
# copies the key as 1 line to your clipboard,
# paste this one instead of <RSA PRIVATE KEY>
$ awk -v ORS='\\n' '1' private.pem | pbcopy
# paste this one instead of <RSA PUBLIC KEY>
$ awk -v ORS='\\n' '1' public.pem | pbcopy
Windows: 😢
# copies the key as 1 line to your clipboard,
# paste this one instead of <RSA PRIVATE KEY>
$ cat private.pem | tr -d '\n' | clip
# paste this one instead of <RSA PUBLIC KEY>
$ cat public.pem | tr -d '\n' | clip
(RECOMMENDED) With docker-compose (creates postgres & pgadmin for you):
$ nvm use # This will use the node version from .nvmrc
$ npm install
$ npx prisma generate
# --build is necessary on the first time or after the Dockerfile was changed
$ docker-compose up --build
Without docker-compose:
Notice that without docker-compose you will need to have your own postgres
$ nvm use # This will use the node version from .nvmrc
$ npm install
$ npx prisma generate
# Don't forget to bring your own postgres and set it in the .env file
$ npm run start:dev:migrate # Or run "Debug Locally" in VSCode
# Runs pending migrations them starts the server in dev mode with nodemon
$ npm run start:dev:migrate
# Generates a new migration after updating prisma schema
$ npm run migrations:generate <migration-name>
# Generates prisma client again after updating prisma schema
$ npx prisma generate
# SSH into a docker container (without docker-compose)
$ docker ps
# Copy you CONTAINER ID from the output of this command
$ docker exec -it <container id hash> sh
# Alternatively you can just (api is the name in our docker-compose file)
$ docker-compose run api sh
- Style guide explaining the different layers and features of the template
- Swagger documentation using jsdoc comments use this article for reference
- Validation of request DTOs using class-transformer & class-validator
- Redis integration as cache
- A separate process for running tasks using BullMQ with integrated UI (this depends on redis)
- Change the infra to Terraform
- Support separate pipelines github actions for "Release" & "Deploy"
Contact Doron Feldman At [email protected]