Skip to content

A simple and secure notes app built with Express.js, TypeScript, Prisma ORM, and PostgreSQL. It features JWT-based authentication, bcrypt.js for password hashing, input validation with express-validator, and request rate limiting with express-rate-limit for enhanced security and performance.

Notifications You must be signed in to change notification settings

KhaledSaeed18/Express-Notes-App-with-TypeScript-Prisma-PostgreSQL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Express TypeScript Backend with Prisma

Node.js TypeScript Express.js Prisma PostgreSQL JWT bcrypt Express Validator Rate Limit CORS

A robust REST API backend built with Express.js, TypeScript, and Prisma ORM featuring authentication and note management.

Features

  • 🔐 JWT-based Authentication
  • 📝 CRUD operations for Notes
  • 🔍 Search functionality
  • 📄 Pagination support
  • ⚡ Rate limiting
  • 🔒 Password validation and security
  • 🎯 Input validation
  • 🚫 Error handling middleware
  • 📦 PostgreSQL database with Prisma ORM

Tech Stack

  • Node.js
  • Express.js
  • TypeScript
  • Prisma ORM
  • PostgreSQL
  • JSON Web Tokens
  • bcrypt.js
  • express-validator
  • express-rate-limit

Installation

1- Clone the repository:

git clone https://github.com/KhaledSaeed18/Express-Notes-App-with-TypeScript-Prisma-PostgreSQL.git
cd Express-Notes-App-with-TypeScript-Prisma-PostgreSQL

2- Install dependencies:

npm install

3- Create a .env file in the root directory:

PORT=<port-number>
API_VERSION=v1
BASE_URL=/api
DATABASE_URL=postgresql://<username>:<password>@localhost:5432/<database-name>
JWT_SECRET=your-jwt-secret-key
JWT_REFRESH_SECRET=your-jwt-refresh-secret-key

4- Set up the database:

npx prisma migrate dev   # Apply the migrations

npx prisma generate   # Generate the Prisma Client

5- Run the application:

npm run dev

6- Production Build:

npm run build
npm start

API Endpoints

Base URL

http://localhost:3000/api/v1

  • Authentication:

    • POST /api/v1/auth/signup - Register a new user
    • POST /api/v1/auth/signin - Login user
    • POST /api/v1/auth/refresh-token - Refresh access token
  • Notes:

    • POST /api/v1/note/create-note - Create a new note
    • GET /api/v1/note/get-notes - Get all notes (paginated)
    • GET /api/v1/note/get-note/:id - Get a specific note
    • GET /api/v1/note/search-notes - Search notes (paginated)
    • PUT /api/v1/note/update-note/:id - Update a note
    • DELETE /api/v1/note/delete-note/:id - Delete a note

About

A simple and secure notes app built with Express.js, TypeScript, Prisma ORM, and PostgreSQL. It features JWT-based authentication, bcrypt.js for password hashing, input validation with express-validator, and request rate limiting with express-rate-limit for enhanced security and performance.

Topics

Resources

Stars

Watchers

Forks