Skip to content

samer12332/Blog_prisma

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blog Prisma API

RESTful blog backend built with Node.js, TypeScript, Express, and Prisma.

Features

  • JWT-based authentication (register, login, logout)
  • Role-based access (USER, EDITOR, ADMIN)
  • Post CRUD with publishing workflow
  • Comments system with moderation-ready model
  • Tags and post categorization
  • Pagination and search endpoints
  • Redis-backed token blacklisting for logout sessions
  • PostgreSQL persistence via Prisma ORM

Tech Stack

  • Node.js
  • TypeScript
  • Express
  • Prisma ORM
  • PostgreSQL
  • Redis
  • JSON Web Token (JWT)
  • bcrypt
  • express-validator
  • express-rate-limit

Project Structure

src/
  controllers/
  middlewares/
  routes/
  services/
  utils/
prisma/
  migrations/
  schema.prisma

Getting Started

1. Install dependencies

npm install

2. Configure environment variables

Create/update .env with at least:

PORT=3001
DATABASE_URL=postgresql://USER:PASSWORD@HOST:PORT/DB_NAME
ACCESS_TOKEN_SECRET=your_jwt_secret
REDIS_URL=redis://localhost:6379

3. Run Prisma migrations

npx prisma migrate dev

4. Start development server

npm run dev

Server runs on http://localhost:3001 by default.

Available Scripts

  • npm run dev - start development server with nodemon
  • npm run build - compile TypeScript
  • npm run start - run compiled build

API Route Groups

  • /api/auth
  • /api/admin
  • /api/posts
  • /api/comments
  • /api/users
  • /api/tags
  • /api/analytics

Admin Tag Management

/api/admin also includes endpoints to attach and remove tags from a specific post.

Database Models (Prisma)

  • User
  • Post
  • Comment
  • Tag

Repository

https://github.com/samer12332/Blog_prisma

Commit Message Convention

Use descriptive commit messages in this format:

  • feat: add admin endpoint to assign tags to posts
  • fix: validate tag ID before disconnecting from post
  • docs: update README with setup and route details

About

Blog project with posts, tags and comments

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors