A containerized boilerplate for a TypeScript-first NestJS backend with code-first GraphQL, JWT (Passport) authentication, MongoDB (MikroORM), and concise (Unit & E2E) tests.
- Code-first GraphQL, with Apollo Sandbox integration (GraphQL IDE)
- Persistence: MikroORM (MongoDB driver)
- Testing (Vitest): AAA, GraphQL E2E, Codecov
- JWT Authentication (Nest/Passport)
- Architecture: Domain-driven file structure
- Configuration: Environment variables (dotenv)
- Strong typing (TypeScript) and validation (class-validator)
- Containerization: Docker
- Continuous Integration: GitHub Actions
- Node.js (tested with v18 and newer)
- MongoDB (tested with Community Server v7)
-
Clone the repository.
-
Provide environment variables in
.env.development:# copy the example/defaults cp .env.example .env.developmentYou can change the values in the
.env.developmentfile to match your environment. The default MONGO_URI targets a typical locally running MongoDB server instance (127.0.0.1:27017). -
Install the project dependencies:
npm install
Development mode (with hot-reload):
npm run start:dev...or without hot-reload:
npm run startProduction mode:
npm run start:prodAfter running the app, you can access the GraphQL sandbox at http://localhost:8008/graphql
npm run test
npm run test:watch # watch mode
npm run test:cov # coverage
npm run test:debug # debugCoverage report for unit tests are exported to ./coverage/unit/.
An in-memory MongoDB server is used for the E2E tests, so you don't need to have a MongoDB server running.
npm run test:e2e
npm run test:e2e:cov # coverageCoverage report for E2E tests are exported to ./coverage/e2e/.