This is starter of a Nest.js 10 application with Prisma ORM, PostgreSQL, Redis and GraphQL.
- JWT Authentication
- Prisma ORM
- GraphQL
- Apollo Driver for GraphQL
- Docker Compose
- PostgreSQL
- Redis
- Health Check
- Prisma
- Redis (using @nestjs/cache-manager)
- Node.js >= 16
- NPM
- Nest.js 10
- Docker
- Docker Compose
- Create volume for PostgreSQL database
docker volume create --name postgres_data0 -d local
- Setup env files.
They should be in config
folder, where you can find .env
templates for them.
- Install dependencies
npm install
- Start DB containers
npm run db:up
- Generate Prisma Types
npm run db:generate
- Push PostgreSQL Schema
npm run db:push
- Start the application
npm run start:dev
Project is using Apollo driver for managing GraphQL, so by default - there's avalaible http://localhost:3000/graphql
request, which is accessible from browser, where you can use GraphQL with auto-generated schemas, docs and write queries and mutations with autocomplete feature.
For unit tests there's Jest module, that will look for *.spec.ts
files.
To run tests just exec:
npm run test
Also, we can have set up E2E testing. With npm run db:up
we already started a testing database, that will be used as a clean e2e environment. All e2e tests are located in tests/e2e
folder, and should be specified in base.e2e-spec.ts
as followed:
// base.e2e-spec.ts
describe('YourResolver (e2e)', yourTests.bind(null, ctx));
// tests/e2e/modules/yourModule/your.resolver.e2e.ts
import BaseContext from '@tests/e2e/context/base-context';
const yourTests = (ctx: BaseContext) => {
// ...
};
To run them, use:
npm run test:e2e
Notice: When starting in E2E mode, testing db is always cleaned up before tests