This is a backend starter template based on Nest framework with completed setup of GraphQL and Prisma. The purpose of using the project is to minimize the redundant effort to setup a backend project from scratch. All of the basic setup done for you.
- Node: v20.x
- Nest CLI: 10.1.11
- Prisma CLI: 5.5.2
- Download zip or click "Use this template"
- Run
npm install
to install packages - Run
npm run migrate
to generates SQL files and seed dummy data - Run
npm run start:dev
to run locally with watch mode
Nest with GraphQL and Prisma
Not only nest is a framework for building robust backend applications but also configuring GraphQL and Prisma with the typescript OOP concepts. In the boilerplate, GraphQL is configured with code first approach. You can see the GraphQL configuration here. Prisma is ORM for databases that can use as an alternative to writing plain SQL. The boilerplate configures Prisma to use SQLite for now but you can change to other databases i.e. PostgreSQL, MySQL, MongoDB.
Security and Monitoring
A health check represents a summary of health indicators. A health indicator executes a check of service, whether it is healthy or unhealthy. You'll be able to check the health status at http://localhost:8080/health once you spin up the backend template. The healthcheck module is defined here. A common technique to protect applications from brute-force attacks is rate-limiting. throttle module is a module to configure rate limiting.
Development environment
Environment variables, listing, code formatting, and testing are all configured for you as well as CI with Github action. You can see the config module to see how the environment variables are configured. Also Husky configuration is done for you to avoid unexpected errors happens while developing. In case linting and testing does not triggered on commit, please run npx husky install
to enable git hook. Such tests often span a variety of types, including unit tests, end-to-end (e2e) tests, integration tests, and so on. Nest strives to promote the development best practices, including effective testing. Editor configuration is also done for you if you are using VSCode you'll be able to format code when you save.
Infrastructure
You can deploy the template with Cloud Build and Cloud Run with terraform. Cloud Run is a serverless platform from Google Cloud to deploy and run containers. Itβs fully managed, autoscallable, and has a generous free tier. Cloud Build is CI/CD platform to build, test and deploy to Cloud Run. Please read README how to spin up the template with terraform.
$ npm install
$ npm run migrate
# dev
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
# eslint
$ npm run lint
# prettier
$ npm run format
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
This project is available under the MIT license. See the LICENSE file for more info.