Skip to content
/ ts-express-prisma Public template

Get started on your next TypeScript-Prisma-Express.js project with ease! Our template includes everything you need, from prettier eslint and tests to a Docker-compose file. Kickstart your development process and build with confidence.

License

Notifications You must be signed in to change notification settings

pshaddel/ts-express-prisma

Repository files navigation

Maintenance Maintaner Ask Me Anything ! codecov GitHub license PRs Welcome

Nodejs Typscript Express Prisma Postgres [Sample Backend Template]

A Boilerplate for Express Apps with Prisma

This repo includes some features that are important to me:

  • using Typescript
  • Hot Reload in Development
  • Using Docker for running Database
  • Using a ORM/ODM for the Database(in this case Prisma)
  • Linting
  • Formatter
  • Validator
  • Testing(Both unit and integration)
  • Using Conventional Commit(Forced by commitlint package)
  • Having Git Hooks(using Husky => pre/post)
  • Documentation(use TS Docs, JS Docs and typedoc package to turn them to html pages)
  • Having a proper pipeline(install, build, lint, format, test)

Prerequisites

Nodejs and NPM: You can install the latest version here

docker: Install docker engine from here.

Quick Start

First install dependencies:

npm install

And then start the project:

npm run start:dev

Now the service is up and is listening on: http://127.0.0.1:3001

Be aware that you need DATABASE_URL as a env variable on your system for running the project or tests. You can create a .env file in Prisma folder to do that.

Testing

We are using Jest as both test library and test runner. For running ts test files we are using SWC which is a lot faster than TS-NODE. This issue of detecting open handles on tests is open on jest: prisma/prisma#18146

Available scripts in package.json file:

npm run test
npm run test:watch
npm run test:ci

Be aware that you need DATABASE_URL as a env variable on your system for running the project or tests. You can create a .env file in Prisma folder to do that.

Test Coverage Badge

For using your own coverage badge you need to do 3 things:

  • Register in CodeCov
  • Copy the Secret CODECOV_TOKEN value and add it to your project secrets.
  • Copy the Badge address from CodeCov dashboard to README file.

Linter and Formatter

For Linting and Formatting we are using Biome

npm run lint
npm run format

Git Commit Message

It is forced to commit Conventional Commit to this repository. For commiting in this style you can use this VSCode Extension or use this CLI Tool that I implemented.

How to Disable it?

Got to .husky/commit-msg and comment the line that checks commit message. You can also remove these two packagees if you do not want to have a standard on commit messages: "@commitlint/cli": "^17.4.4", "@commitlint/config-conventional": "^17.4.4"

Documents

Add your documents as TS comments in your project and then run this command for generating .MD files in docs folder:

npm run docs

Validation

We are using Zod for validation of requests. Check out src/user.service.ts to see the example.

Pipeline

Pipeline has these steps:

  • Installing Dependencies
  • Lint
  • Run Test Containers
  • Wait
  • Test

About

Get started on your next TypeScript-Prisma-Express.js project with ease! Our template includes everything you need, from prettier eslint and tests to a Docker-compose file. Kickstart your development process and build with confidence.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published