This is our base project template for web applications, APIs, and administrative portals. The goal is to make starting a new app project simple, yet come with all the things we're accustomed to having on our projects - such as testing, utilities, deployment configurations, etc.
Email john@betablox.com to have create your personal demo account
cp .env.example .env
Now modify .env
as needed
# Install your deps
$ npm install
# Run docker services
$ npm run docker:up
# Reset and seed your database
$ npm run db:reset
# Run build once for turbo cache
$ npm run build
$ npm run dev
$ npm run build
# Start the production web application and API
$ npm run start
# Or Start the production admin portal which runs on port 8001
$ npm run start:admin
We have created individual test commands in package.json
so that tests can run independently of each other without running into database issues such as deadlocks.
The approriate test commands for our CI environment are found .github/workflows/ci.yml
# Run individual app test suite
$ npm run test:client
$ npm run test:api
# Or a shared package
$ npm run test:utils
$ npm run test:database
$ npm run test:types
$ npm run test:paginator
# See package.json for all testing commands
We encourage you to write tests and whatever level you are comfortable (e2e, integration, unit, etc.)
As a general rule of thumb we like to have tests for our backend APIs at either the controller or service level in NestJS. Furthermore, we will mainly stick to integration level tests because the tradeoffs of hitting HTTP layer to database coverage generally outweigh the benefits of hundreds of isolated unit tests.
Unit tests are saved for unique situations such as utility or helper methods. For example, a helper method that converts a dollars to cents or another that manipulates a string won't require much more than a few simple tests.
All documentation for our CI process is found in .github/workflows/ci.yml
which will utilize Github Actions when making a pull request or merging into master
Our recommended approach for CD is to use Railway it's generally very easy to setup a new project, set your environment variables, and deploy master
directly with our Dockerfile
If your project needs a production ready database, we recommend looking at Supabase. You can generally boot up a new Postgres database, connect it to your Railway app, and deploy in less than 10 minutes.
As you build your project out from this template, please remember to pay it forward and improve the template. Even a seemingly simple change such as a new util method is helpful.
You can either:
Heavily inspired by this YouTube video https://www.youtube.com/watch?v=nY0R7pslbCI