VOOZH about

URL: https://dev.to/nabinkdl/nestjs-prisma-v7-vercel-starter-h70

⇱ πŸš€ NestJS + Prisma V7 + Vercel Starter - DEV Community


A minimal, production‑ready REST API with JWT authentication and todo CRUD, built with NestJS, Prisma v7, and PostgreSQL β€” optimised for Vercel serverless deployment.

Stop wrestling with boilerplate. Clone this, configure your database, and you've got a live API in minutes.


✨ What's included

  • πŸ” JWT auth – register and login endpoints ready to go
  • πŸ“ Full todo CRUD – each user manages their own private list
  • 🧩 Clean NestJS architecture – separate modules for auth, todo, and a shared prisma service
  • ⚑ Serverless‑ready – Prisma client singleton prevents connection exhaustion on Vercel
  • πŸ› οΈ Zero‑config deployment – push to GitHub, import to Vercel, done

⚑ Quick Setup

1. Clone and rename

git clone https://github.com/nabinkdl/Nest-setup my-app
cd my-app

Rename my-app to whatever fits your project. Then start fresh:

rm -rf .git && git init

2. Set project metadata (no manual editing)

npm pkg set name="your-name"
npm pkg set description="this is your description"
npm pkg set author="your name"
npm pkg set license="MIT"

3. Install dependencies

bun install # you can also use npm or yarn

4. Configure your database

cp .env.example .env

Open .env and add your PostgreSQL connection string:

DATABASE_URL="postgresql://user:password@host:5432/mydb?schema=public"
Provider Connection string tip
Neon append ?sslmode=require
Supabase append ?pgbouncer=true
Railway use the provided string as‑is

5. Run the migration

bunx prisma migrate dev --name init

(Optional) Explore your data with Prisma Studio:

bunx prisma studio

6. Start developing

bun run start:dev

Your API is now live at http://localhost:3000 πŸŽ‰


☁️ Deploy to Vercel

  1. Push your repo to GitHub.
  2. Import the project on vercel.com/new.
  3. Add the environment variables:
    • DATABASE_URL – your PostgreSQL connection string
    • NODE_ENV – production
  4. Hit Deploy – Vercel will automatically run:
 bunx prisma generate && bun run build

Your serverless NestJS API is now live!


πŸ“‘ API Endpoints

All /todos routes require a JWT Bearer token in the Authorization header.

Method Route Body (JSON) Description
POST /auth/register {"email": "user@test.com", "password": "123"} Register a new user
POST /auth/login {"email": "user@test.com", "password": "123"} Login, receive a JWT
GET /todos – List all user's todos
GET /todos/:id – Get a single todo
POST /todos {"title": "Buy milk"} Create a todo
PATCH /todos/:id {"title": "Buy milk updated"} Update a todo
DELETE /todos/:id – Delete a todo

Try it with curl, Postman, or your future frontend.


πŸ“ Project Structure

src/
β”œβ”€β”€ app.module.ts # Root module
β”œβ”€β”€ app.controller.ts # Root controller
β”œβ”€β”€ main.ts # App entry point
β”œβ”€β”€ common/ # Shared utilities
β”‚ β”œβ”€β”€ decorators/ # @CurrentUser, etc.
β”‚ └── guards/ # JwtAuthGuard
β”œβ”€β”€ core/
β”‚ └── prisma/ # Prisma module & service (singleton)
└── modules/
 β”œβ”€β”€ auth/ # Auth module (register, login, JWT)
 └── todo/ # Todo CRUD module

prisma/
β”œβ”€β”€ schema.prisma # Database schema
└── migrations/ # Prisma migration files

Everything is intentionally minimal so you can understand and extend it with confidence.


πŸ’‘ Notes

  • Singleton Prisma client – The PrismaService reuses a single client instance across serverless invocations to avoid exhausting database connections.
  • Never commit .env – use .env.example as a safe template for your team.
  • Best for – hobby projects, small startups, hackathons, or as a learning base. Need rate limiting or more complex logic? The architecture is clean enough to scale with your needs.