A starter template for any Enterprise Applications, Rest APIs or Microservices with Node.js, Express and Prisma ORM for MySQL, PostgreSQL or others. This project offers production ready environment with all necessary supports for validation, unit testing, socket, redis and many more.
Clone the repo:
git clone https://github.com/ItzSamdam/nodejs-prisma-orm-typescript.git
cd nodejs-prisma-orm-typescript
Install the dependencies:
npm install
Start coding ....
Database Connection
datasource db {
//provider = "mysql", "postgres", "mongodb" ...
provider = "mysql";
//url = database url
url = env("DATABASE_URL");
}
Models
prisma\
- schema.prisma
//declare model Modelname
model User {
id Int @id @default(autoincrement())
email String @unique
password String
}
prisma\ # Prisma ORM and Data Model
src\
|--config\ # Environment variables and configuration related things
|--controllers\ # Route controllers (controller layer)
|--dtos\ # Data Transfer Object for models
|--exceptions\ # Http Exception Handler
|--interfaces\ # typescript interface handler
|--middlewares\ # Provide Security Layer in app
|--routes\ # Routes
|--services\ # Business logic (service layer)
|--utilities\ # Utilities classes, loggers etc
|--test # test files
|--app-main.ts # Express app
|--server.ts # App entry point