/backend-node-sql-starter

Production-grade Node.js boilerplate with TypeScript, Prisma, Jest, ESLint, and full test coverage. Ready for your next project.

Primary LanguageTypeScriptMIT LicenseMIT

backend-node-sql-starter

Production-grade Node.js boilerplate. Ready for your next project.

Tech Stack:

  • Node.js
  • TypeScript
  • Express.js
  • Zod
  • Prisma
  • Winston
  • PostgreSQL
  • Jest
  • Supertest
  • Docker Compose

Setup:

Requirements:

  • Node.js (v20)
  • Docker

Environment variables:

Environment variables for development:

cp .env.example .env

Update the .env file with the correct values. For database credentials, use the values from the docker-compose.yml file.

Environment variables for testing:

cp .env.test.example .env.test

Update the .env.test file with the correct values. For database credentials, use the values from the docker-compose.yml file.

Installation:

Install dependencies:

npm install

Database:

Create PostgreSQL databases using Docker Compose:

docker compose up -d

Run migrations for main database:

npm run db-migrate

Run migrations for test database:

npm run db-test-migrate

Running the app:

For development:

npm run dev

For production:

Build the app:

npm run build

Start the server:

npm start

Testing the app:

Run only unit tests:

npm run test:unit

Run only integration tests:

npm run test:integration

Run all tests (unit and integration):

npm test